Skip to content

Commit

Permalink
fix(cli): Add firebase config
Browse files Browse the repository at this point in the history
  • Loading branch information
vanlooverenkoen committed Nov 21, 2023
1 parent ae1abc2 commit b620f60
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
- run: flutter packages get
- run: dart analyze
- run: flutter build web --dart-define=FIREBASE_API_KEY=$FIREBASE_API_KEY --dart-define=FIREBASE_APP_ID=${{secrets.FIREBASE_APP_ID}} --dart-define=FIREBASE_MESSAGING_SENDER_ID=${{secrets.FIREBASE_MESSAGING_SENDER_ID}} --dart-define=FIREBASE_PROJECT_ID=${{secrets.FIREBASE_PROJECT_ID}} --dart-define=FIREBASE_AUTH_DOMAIN=${{secrets.FIREBASE_AUTH_DOMAIN}} --dart-define=FIREBASE_STORAGE_BUCKET=${{secrets.FIREBASE_STORAGE_BUCKET}} --dart-define=FIREBASE_MEASUREMENT_ID=${{secrets.FIREBASE_MEASUREMENT_ID}}
- run: flutter build web
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
Expand Down
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,4 @@ app.*.map.json
/android/app/release

# FVM
.fvm/flutter_sdk

# Firebase
lib/firebase_options.dart
.fvm/flutter_sdk
4 changes: 2 additions & 2 deletions lib/firebase_init.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter_belgium/di/injectable.dart';
import 'package:flutter_belgium/firebase_options.dart';
import 'package:flutter_belgium/repo/login_repo.dart';
import 'package:flutter_belgium/util/firebase/firebase_config.dart';

Future<void> initFirebase() async {
await Firebase.initializeApp(options: FirebaseConfig.currentPlatform);
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
getIt<LoginRepository>().init();
}
63 changes: 63 additions & 0 deletions lib/firebase_options.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// File generated by FlutterFire CLI.
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform;

/// Default [FirebaseOptions] for use with your Firebase apps.
///
/// Example:
/// ```dart
/// import 'firebase_options.dart';
/// // ...
/// await Firebase.initializeApp(
/// options: DefaultFirebaseOptions.currentPlatform,
/// );
/// ```
class DefaultFirebaseOptions {
static FirebaseOptions get currentPlatform {
if (kIsWeb) {
return web;
}
switch (defaultTargetPlatform) {
case TargetPlatform.android:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for android - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.iOS:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for ios - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.macOS:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for macos - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.windows:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for windows - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.linux:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for linux - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
default:
throw UnsupportedError(
'DefaultFirebaseOptions are not supported for this platform.',
);
}
}

static const FirebaseOptions web = FirebaseOptions(
apiKey: 'AIzaSyDQo5SlRMWBIyzjNN4MvMaO1fhjs83Nui8',
appId: '1:755875347425:web:4f90d9bec1021df43630a0',
messagingSenderId: '755875347425',
projectId: 'flutter-belgium',
authDomain: 'flutter-belgium.firebaseapp.com',
storageBucket: 'flutter-belgium.appspot.com',
measurementId: 'G-XT58Y3Y0E6',
);
}
2 changes: 0 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import 'package:flutter_belgium/di/injectable.dart';
import 'package:flutter_belgium/firebase_init.dart';

Future<void> main() async {
const value = String.fromEnvironment('FIREBASE_PROJECT_ID');
print(value);
configureDependencies();
await initFirebase();
runApp(const MyApp());
Expand Down
27 changes: 0 additions & 27 deletions lib/util/firebase/firebase_config.dart

This file was deleted.

0 comments on commit b620f60

Please sign in to comment.