Skip to content

Commit 3d5c8e3

Browse files
committed
add firebase_options.dart
1 parent 3ab8ccc commit 3d5c8e3

File tree

3 files changed

+82
-11
lines changed

3 files changed

+82
-11
lines changed

firebase_ai_logic_showcase/.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,3 @@ ephemeral/
5252
google-services.json
5353
GoogleService-Info.plist
5454
.firebaserc
55-
firebase.json
56-
57-
# Firebase options file
58-
lib/firebase_options.dart

firebase_ai_logic_showcase/.idx/dev.nix

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
packages = [
88
pkgs.jdk21
99
pkgs.unzip
10-
pkgs.nodePackages.nodemon
1110
pkgs.nodejs_22
11+
pkgs.nodePackages.nodemon
1212
];
1313
# Sets environment variables in the workspace
1414
env = {
@@ -27,10 +27,10 @@
2727
idx = {
2828
# Search for the extensions you want on https://open-vsx.org/ and use "publisher.id"
2929
extensions = [
30-
"Dart-Code.flutter"
31-
"Dart-Code.dart-code"
3230
"hashicorp.terraform"
3331
"ms-vscode.js-debug"
32+
"Dart-Code.flutter"
33+
"Dart-Code.dart-code"
3434
];
3535
workspace = {
3636
# Runs when a workspace is first created with this `dev.nix` file
@@ -51,10 +51,10 @@
5151
command = [ "flutter" "run" "--machine" "-d" "web-server" "--web-hostname" "0.0.0.0" "--web-port" "$PORT" ];
5252
manager = "flutter";
5353
};
54-
android = {
55-
command = [ "flutter" "run" "--machine" "-d" "android" "-d" "localhost:5555" ];
56-
manager = "flutter";
57-
};
54+
# android = {
55+
# command = [ "flutter" "run" "--machine" "-d" "android" "-d" "localhost:5555" ];
56+
# manager = "flutter";
57+
# };
5858
};
5959
};
6060
};
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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

Comments
 (0)