Skip to content

Commit 85ea2d2

Browse files
authored
feat: add firebase config to example (#246)
* feat: add firebase config to example * chore: format * feat: initializeApp at main
1 parent 05e307b commit 85ea2d2

File tree

7 files changed

+138
-1
lines changed

7 files changed

+138
-1
lines changed

example/android/app/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ if (flutterVersionName == null) {
2222
}
2323

2424
apply plugin: 'com.android.application'
25+
// START: FlutterFire Configuration
26+
apply plugin: 'com.google.gms.google-services'
27+
apply plugin: 'com.google.firebase.firebase-perf'
28+
// END: FlutterFire Configuration
2529
apply plugin: 'kotlin-android'
2630
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2731

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"project_info": {
3+
"project_number": "223276840801",
4+
"project_id": "flutter-gen-5b267",
5+
"storage_bucket": "flutter-gen-5b267.appspot.com"
6+
},
7+
"client": [
8+
{
9+
"client_info": {
10+
"mobilesdk_app_id": "1:223276840801:android:8c43b96e396a1781b77720",
11+
"android_client_info": {
12+
"package_name": "com.example.example"
13+
}
14+
},
15+
"oauth_client": [
16+
{
17+
"client_id": "223276840801-vd883eedtkum45svga4m9dqpppacohpi.apps.googleusercontent.com",
18+
"client_type": 3
19+
}
20+
],
21+
"api_key": [
22+
{
23+
"current_key": "AIzaSyBqCLgp5h6_dHlMJzKSsCfnSFawfFjCK1c"
24+
}
25+
],
26+
"services": {
27+
"appinvite_service": {
28+
"other_platform_oauth_client": [
29+
{
30+
"client_id": "223276840801-vd883eedtkum45svga4m9dqpppacohpi.apps.googleusercontent.com",
31+
"client_type": 3
32+
}
33+
]
34+
}
35+
}
36+
}
37+
],
38+
"configuration_version": "1"
39+
}

example/android/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ buildscript {
77

88
dependencies {
99
classpath 'com.android.tools.build:gradle:7.2.0'
10+
// START: FlutterFire Configuration
11+
classpath 'com.google.gms:google-services:4.3.10'
12+
classpath 'com.google.firebase:perf-plugin:1.4.1'
13+
// END: FlutterFire Configuration
1014
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1115
}
1216
}

example/ios/Podfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ PODS:
240240
- Flutter
241241
- in_app_review (0.2.0):
242242
- Flutter
243+
- integration_test (0.0.1):
244+
- Flutter
243245
- is_firebase_test_lab_activated (0.0.1):
244246
- Flutter
245247
- libwebp (1.2.1):
@@ -336,6 +338,7 @@ DEPENDENCIES:
336338
- image_editor (from `.symlinks/plugins/image_editor/ios`)
337339
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
338340
- in_app_review (from `.symlinks/plugins/in_app_review/ios`)
341+
- integration_test (from `.symlinks/plugins/integration_test/ios`)
339342
- is_firebase_test_lab_activated (from `.symlinks/plugins/is_firebase_test_lab_activated/ios`)
340343
- local_auth_ios (from `.symlinks/plugins/local_auth_ios/ios`)
341344
- native_device_orientation (from `.symlinks/plugins/native_device_orientation/ios`)
@@ -444,6 +447,8 @@ EXTERNAL SOURCES:
444447
:path: ".symlinks/plugins/image_picker_ios/ios"
445448
in_app_review:
446449
:path: ".symlinks/plugins/in_app_review/ios"
450+
integration_test:
451+
:path: ".symlinks/plugins/integration_test/ios"
447452
is_firebase_test_lab_activated:
448453
:path: ".symlinks/plugins/is_firebase_test_lab_activated/ios"
449454
local_auth_ios:
@@ -532,6 +537,7 @@ SPEC CHECKSUMS:
532537
image_editor: c1d038630eedea60d2dee9c14f36aa66c7f9cfab
533538
image_picker_ios: b786a5dcf033a8336a657191401bfdf12017dabb
534539
in_app_review: 4a97249f7a2f539a0f294c2d9196b7fe35e49541
540+
integration_test: a1e7d09bd98eca2fc37aefd79d4f41ad37bdbbe5
535541
is_firebase_test_lab_activated: 84effe92e5d79a58455a2861b5e1ba688016cf57
536542
libwebp: 98a37e597e40bfdb4c911fc98f2c53d0b12d05fc
537543
local_auth_ios: 0d333dde7780f669e66f19d2ff6005f3ea84008d

example/ios/firebase_app_id_file.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"file_generated_by": "FlutterFire CLI",
3+
"purpose": "FirebaseAppID & ProjectID for this Firebase app in this directory",
4+
"GOOGLE_APP_ID": "1:223276840801:ios:b5be85aa3c64059db77720",
5+
"FIREBASE_PROJECT_ID": "flutter-gen-5b267",
6+
"GCM_SENDER_ID": "223276840801"
7+
}

example/lib/firebase_options.dart

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// File generated by FlutterFire CLI.
2+
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
3+
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
4+
import 'package:flutter/foundation.dart'
5+
show defaultTargetPlatform, kIsWeb, TargetPlatform;
6+
7+
/// Default [FirebaseOptions] for use with your Firebase apps.
8+
///
9+
/// Example:
10+
/// ```dart
11+
/// import 'firebase_options.dart';
12+
/// // ...
13+
/// await Firebase.initializeApp(
14+
/// options: DefaultFirebaseOptions.currentPlatform,
15+
/// );
16+
/// ```
17+
class DefaultFirebaseOptions {
18+
static FirebaseOptions get currentPlatform {
19+
if (kIsWeb) {
20+
throw UnsupportedError(
21+
'DefaultFirebaseOptions have not been configured for web - '
22+
'you can reconfigure this by running the FlutterFire CLI again.',
23+
);
24+
}
25+
switch (defaultTargetPlatform) {
26+
case TargetPlatform.android:
27+
return android;
28+
case TargetPlatform.iOS:
29+
return ios;
30+
case TargetPlatform.macOS:
31+
throw UnsupportedError(
32+
'DefaultFirebaseOptions have not been configured for macos - '
33+
'you can reconfigure this by running the FlutterFire CLI again.',
34+
);
35+
case TargetPlatform.windows:
36+
throw UnsupportedError(
37+
'DefaultFirebaseOptions have not been configured for windows - '
38+
'you can reconfigure this by running the FlutterFire CLI again.',
39+
);
40+
case TargetPlatform.linux:
41+
throw UnsupportedError(
42+
'DefaultFirebaseOptions have not been configured for linux - '
43+
'you can reconfigure this by running the FlutterFire CLI again.',
44+
);
45+
default:
46+
throw UnsupportedError(
47+
'DefaultFirebaseOptions are not supported for this platform.',
48+
);
49+
}
50+
}
51+
52+
static const FirebaseOptions android = FirebaseOptions(
53+
apiKey: 'AIzaSyBqCLgp5h6_dHlMJzKSsCfnSFawfFjCK1c',
54+
appId: '1:223276840801:android:8c43b96e396a1781b77720',
55+
messagingSenderId: '223276840801',
56+
projectId: 'flutter-gen-5b267',
57+
storageBucket: 'flutter-gen-5b267.appspot.com',
58+
);
59+
60+
static const FirebaseOptions ios = FirebaseOptions(
61+
apiKey: 'AIzaSyChOfD8XNEdGZtB3Gdqg9J5GRLgUuH9jo8',
62+
appId: '1:223276840801:ios:b5be85aa3c64059db77720',
63+
messagingSenderId: '223276840801',
64+
projectId: 'flutter-gen-5b267',
65+
storageBucket: 'flutter-gen-5b267.appspot.com',
66+
iosClientId:
67+
'223276840801-p876k56nj46ka6r8bmhkj5s6qiopoe1l.apps.googleusercontent.com',
68+
iosBundleId: 'com.example.example',
69+
);
70+
}

example/lib/main.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1+
import 'package:firebase_core/firebase_core.dart';
12
import 'package:flutter/material.dart';
23
import 'package:example_resources/gen/assets.gen.dart' as res;
34

5+
import 'firebase_options.dart';
46
import 'gen/assets.gen.dart';
57
import 'gen/colors.gen.dart';
68
import 'gen/fonts.gen.dart';
79

8-
void main() {
10+
void main() async {
11+
WidgetsFlutterBinding.ensureInitialized();
12+
await Firebase.initializeApp(
13+
options: DefaultFirebaseOptions.currentPlatform,
14+
);
15+
916
runApp(MaterialApp(
1017
title: 'Flutter Demo',
1118
theme: ThemeData(

0 commit comments

Comments
 (0)