|
| 1 | +import 'dart:js_interop'; |
| 2 | + |
| 3 | +import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; |
| 4 | +import 'package:flutter/foundation.dart' |
| 5 | + show TargetPlatform, defaultTargetPlatform, kIsWeb; |
| 6 | + |
| 7 | +extension type BootstrapFirebaseOptions._(JSObject _) implements JSObject { |
| 8 | + external String get apiKey; |
| 9 | + external String get authDomain; |
| 10 | + external String get databaseURL; |
| 11 | + external String get projectId; |
| 12 | + external String get storageBucket; |
| 13 | + external String get messagingSenderId; |
| 14 | + external String get appId; |
| 15 | + external String get measurementId; |
| 16 | +} |
| 17 | + |
| 18 | +extension type BootstrapOptions._(JSObject _) implements JSObject { |
| 19 | + external String get geminiApiKey; |
| 20 | + external BootstrapFirebaseOptions get firebase; |
| 21 | +} |
| 22 | + |
| 23 | +@JS() |
| 24 | +// ignore: non_constant_identifier_names |
| 25 | +external BootstrapOptions get APP_TEMPLATE_BOOTSTRAP; |
| 26 | + |
| 27 | +class DefaultFirebaseOptions { |
| 28 | + |
| 29 | + static FirebaseOptions get currentPlatform { |
| 30 | + if (kIsWeb) { |
| 31 | + return web; |
| 32 | + } |
| 33 | + switch (defaultTargetPlatform) { |
| 34 | + case TargetPlatform.android: |
| 35 | + throw UnsupportedError( |
| 36 | + 'DefaultFirebaseOptions have not been configured for android - ' |
| 37 | + 'you can reconfigure this by running the FlutterFire CLI again.', |
| 38 | + ); |
| 39 | + case TargetPlatform.iOS: |
| 40 | + throw UnsupportedError( |
| 41 | + 'DefaultFirebaseOptions have not been configured for ios - ' |
| 42 | + 'you can reconfigure this by running the FlutterFire CLI again.', |
| 43 | + ); |
| 44 | + case TargetPlatform.macOS: |
| 45 | + throw UnsupportedError( |
| 46 | + 'DefaultFirebaseOptions have not been configured for macos - ' |
| 47 | + 'you can reconfigure this by running the FlutterFire CLI again.', |
| 48 | + ); |
| 49 | + case TargetPlatform.windows: |
| 50 | + throw UnsupportedError( |
| 51 | + 'DefaultFirebaseOptions have not been configured for windows - ' |
| 52 | + 'you can reconfigure this by running the FlutterFire CLI again.', |
| 53 | + ); |
| 54 | + case TargetPlatform.linux: |
| 55 | + throw UnsupportedError( |
| 56 | + 'DefaultFirebaseOptions have not been configured for linux - ' |
| 57 | + 'you can reconfigure this by running the FlutterFire CLI again.', |
| 58 | + ); |
| 59 | + // ignore: no_default_cases |
| 60 | + default: |
| 61 | + throw UnsupportedError( |
| 62 | + 'DefaultFirebaseOptions are not supported for this platform.', |
| 63 | + ); |
| 64 | + } |
| 65 | + } |
| 66 | + |
| 67 | + static FirebaseOptions web = FirebaseOptions( |
| 68 | + apiKey: APP_TEMPLATE_BOOTSTRAP.firebase.apiKey, |
| 69 | + appId: APP_TEMPLATE_BOOTSTRAP.firebase.appId, |
| 70 | + messagingSenderId: APP_TEMPLATE_BOOTSTRAP.firebase.messagingSenderId, |
| 71 | + projectId: APP_TEMPLATE_BOOTSTRAP.firebase.projectId, |
| 72 | + authDomain: APP_TEMPLATE_BOOTSTRAP.firebase.authDomain, |
| 73 | + storageBucket: APP_TEMPLATE_BOOTSTRAP.firebase.storageBucket, |
| 74 | + ); |
| 75 | +} |
0 commit comments