Skip to content

Commit 6ac795e

Browse files
authored
Merge pull request #12 from Flutter-Explained/firebase-init
feat: Firebase is initialized for production and development
2 parents 2f3fc4c + aad2f87 commit 6ac795e

File tree

9 files changed

+111
-66
lines changed

9 files changed

+111
-66
lines changed

android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ android {
5252

5353
defaultConfig {
5454
applicationId "dev.flutterexplained.community_app"
55-
minSdkVersion flutter.minSdkVersion
55+
minSdkVersion 23
5656
targetSdkVersion flutter.targetSdkVersion
5757
versionCode flutterVersionCode.toInteger()
5858
versionName flutterVersionName
@@ -77,7 +77,7 @@ android {
7777
}
7878

7979
flavorDimensions "default"
80-
productFlavors {
80+
productFlavors {
8181
production {
8282
dimension "default"
8383
applicationIdSuffix ""

android/app/google-services.json

Lines changed: 17 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,40 @@
11
{
22
"project_info": {
3-
"project_number": "416647339946",
4-
"project_id": "flutter-explained-community",
5-
"storage_bucket": "flutter-explained-community.appspot.com"
3+
"project_number": "904342392027",
4+
"project_id": "fe-community-dev",
5+
"storage_bucket": "fe-community-dev.appspot.com"
66
},
77
"client": [
88
{
99
"client_info": {
10-
"mobilesdk_app_id": "1:416647339946:android:aeee24df2f82f9d1c9d5d3",
10+
"mobilesdk_app_id": "1:904342392027:android:6e23ad729fa926912ad0fe",
1111
"android_client_info": {
12-
"package_name": "com.example.community_app"
13-
}
14-
},
15-
"oauth_client": [
16-
{
17-
"client_id": "416647339946-pcveajdsiu5vvsvhuil30jp316kvba35.apps.googleusercontent.com",
18-
"client_type": 3
19-
}
20-
],
21-
"api_key": [
22-
{
23-
"current_key": "AIzaSyBarisN1l9qgQtmg1hzcEC3FRGw_PrUt8A"
24-
}
25-
],
26-
"services": {
27-
"appinvite_service": {
28-
"other_platform_oauth_client": [
29-
{
30-
"client_id": "416647339946-pcveajdsiu5vvsvhuil30jp316kvba35.apps.googleusercontent.com",
31-
"client_type": 3
32-
},
33-
{
34-
"client_id": "416647339946-g6tmvohc21sce0i12if4g819ptfq5svl.apps.googleusercontent.com",
35-
"client_type": 2,
36-
"ios_info": {
37-
"bundle_id": "com.example.verygoodcore.community-app"
38-
}
39-
}
40-
]
41-
}
42-
}
43-
},
44-
{
45-
"client_info": {
46-
"mobilesdk_app_id": "1:416647339946:android:6a6e9cdce67d0712c9d5d3",
47-
"android_client_info": {
48-
"package_name": "com.example.verygoodcore.community_app"
12+
"package_name": "dev.flutterexplained.community_app"
4913
}
5014
},
5115
"oauth_client": [
5216
{
53-
"client_id": "416647339946-pcveajdsiu5vvsvhuil30jp316kvba35.apps.googleusercontent.com",
17+
"client_id": "904342392027-v6bpbj6kq2igl1nh1atihvtnrg4be8gv.apps.googleusercontent.com",
5418
"client_type": 3
5519
}
5620
],
5721
"api_key": [
5822
{
59-
"current_key": "AIzaSyBarisN1l9qgQtmg1hzcEC3FRGw_PrUt8A"
23+
"current_key": "AIzaSyAvJzjCY2WLdII87qwpQQvUqjw0RcRisGM"
6024
}
6125
],
6226
"services": {
6327
"appinvite_service": {
6428
"other_platform_oauth_client": [
6529
{
66-
"client_id": "416647339946-pcveajdsiu5vvsvhuil30jp316kvba35.apps.googleusercontent.com",
30+
"client_id": "904342392027-v6bpbj6kq2igl1nh1atihvtnrg4be8gv.apps.googleusercontent.com",
6731
"client_type": 3
6832
},
6933
{
70-
"client_id": "416647339946-g6tmvohc21sce0i12if4g819ptfq5svl.apps.googleusercontent.com",
34+
"client_id": "904342392027-q5sb99te7uc07m0td6lg8f9kfo4cbohg.apps.googleusercontent.com",
7135
"client_type": 2,
7236
"ios_info": {
73-
"bundle_id": "com.example.verygoodcore.community-app"
37+
"bundle_id": "dev.flutterexplained.community-app.dev"
7438
}
7539
}
7640
]
@@ -79,34 +43,34 @@
7943
},
8044
{
8145
"client_info": {
82-
"mobilesdk_app_id": "1:416647339946:android:3b8cbe30444a07bbc9d5d3",
46+
"mobilesdk_app_id": "1:904342392027:android:b2991e3e0348c5482ad0fe",
8347
"android_client_info": {
84-
"package_name": "dev.flutterexplained.community_app"
48+
"package_name": "dev.flutterexplained.community_app.dev"
8549
}
8650
},
8751
"oauth_client": [
8852
{
89-
"client_id": "416647339946-pcveajdsiu5vvsvhuil30jp316kvba35.apps.googleusercontent.com",
53+
"client_id": "904342392027-v6bpbj6kq2igl1nh1atihvtnrg4be8gv.apps.googleusercontent.com",
9054
"client_type": 3
9155
}
9256
],
9357
"api_key": [
9458
{
95-
"current_key": "AIzaSyBarisN1l9qgQtmg1hzcEC3FRGw_PrUt8A"
59+
"current_key": "AIzaSyAvJzjCY2WLdII87qwpQQvUqjw0RcRisGM"
9660
}
9761
],
9862
"services": {
9963
"appinvite_service": {
10064
"other_platform_oauth_client": [
10165
{
102-
"client_id": "416647339946-pcveajdsiu5vvsvhuil30jp316kvba35.apps.googleusercontent.com",
66+
"client_id": "904342392027-v6bpbj6kq2igl1nh1atihvtnrg4be8gv.apps.googleusercontent.com",
10367
"client_type": 3
10468
},
10569
{
106-
"client_id": "416647339946-g6tmvohc21sce0i12if4g819ptfq5svl.apps.googleusercontent.com",
70+
"client_id": "904342392027-q5sb99te7uc07m0td6lg8f9kfo4cbohg.apps.googleusercontent.com",
10771
"client_type": 2,
10872
"ios_info": {
109-
"bundle_id": "com.example.verygoodcore.community-app"
73+
"bundle_id": "dev.flutterexplained.community-app.dev"
11074
}
11175
}
11276
]

ios/firebase_app_id_file.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"file_generated_by": "FlutterFire CLI",
33
"purpose": "FirebaseAppID & ProjectID for this Firebase app in this directory",
4-
"GOOGLE_APP_ID": "1:416647339946:ios:7a555c9101c8b460c9d5d3",
5-
"FIREBASE_PROJECT_ID": "flutter-explained-community",
6-
"GCM_SENDER_ID": "416647339946"
4+
"GOOGLE_APP_ID": "1:904342392027:ios:4a2e611a4843f6df2ad0fe",
5+
"FIREBASE_PROJECT_ID": "fe-community-dev",
6+
"GCM_SENDER_ID": "904342392027"
77
}

lib/bootstrap.dart

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import 'package:community_app/firebase_options.dart';
66
import 'package:firebase_core/firebase_core.dart';
77
import 'package:flutter/widgets.dart';
88

9+
enum Environment { dev, staging, prod }
10+
911
class AppBlocObserver extends BlocObserver {
1012
const AppBlocObserver();
1113

@@ -22,14 +24,22 @@ class AppBlocObserver extends BlocObserver {
2224
}
2325
}
2426

25-
Future<void> bootstrap(FutureOr<Widget> Function() builder) async {
27+
Future<void> bootstrap(
28+
FutureOr<Widget> Function() builder,
29+
Environment environment,
30+
) async {
2631
WidgetsFlutterBinding.ensureInitialized();
32+
2733
FlutterError.onError = (details) {
2834
log(details.exceptionAsString(), stackTrace: details.stack);
2935
};
3036

3137
Bloc.observer = const AppBlocObserver();
32-
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
38+
39+
await Firebase.initializeApp(
40+
name: '$environment',
41+
options: DefaultFirebaseOptions.currentPlatform,
42+
);
3343

3444
await runZonedGuarded(
3545
() async => runApp(await builder()),

lib/firebase_options.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ class DefaultFirebaseOptions {
6060

6161
static const FirebaseOptions ios = FirebaseOptions(
6262
apiKey: 'AIzaSyBuKomYEqhbFRtOZWQcNOMrDyUd_XFAAvU',
63-
appId: '1:416647339946:ios:7a555c9101c8b460c9d5d3',
63+
appId: '1:416647339946:ios:51dbead1e89cf4edc9d5d3',
6464
messagingSenderId: '416647339946',
6565
projectId: 'flutter-explained-community',
6666
storageBucket: 'flutter-explained-community.appspot.com',
6767
iosClientId:
68-
'416647339946-rrjtr8rgl3r5fgtdam9ms3slu91snflm.apps.googleusercontent.com',
69-
iosBundleId: 'dev.flutterexplained.community-app',
68+
'416647339946-58vodha5kfr0oh3v6343dd7pf9rhjfc4.apps.googleusercontent.com',
69+
iosBundleId: 'dev.explained.comm',
7070
);
7171
}

lib/firebase_options_dev.dart

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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 TargetPlatform, defaultTargetPlatform, kIsWeb;
6+
7+
/// Default [FirebaseOptions] for use with your Firebase apps.
8+
///
9+
/// Example:
10+
/// ```dart
11+
/// import 'firebase_options_dev.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+
case TargetPlatform.fuchsia:
46+
throw UnsupportedError(
47+
'DefaultFirebaseOptions have not been configured for fuchsia - '
48+
'you can reconfigure this by running the FlutterFire CLI again.',
49+
);
50+
}
51+
}
52+
53+
static const FirebaseOptions android = FirebaseOptions(
54+
apiKey: 'AIzaSyAvJzjCY2WLdII87qwpQQvUqjw0RcRisGM',
55+
appId: '1:904342392027:android:6e23ad729fa926912ad0fe',
56+
messagingSenderId: '904342392027',
57+
projectId: 'fe-community-dev',
58+
storageBucket: 'fe-community-dev.appspot.com',
59+
);
60+
61+
static const FirebaseOptions ios = FirebaseOptions(
62+
apiKey: 'AIzaSyAcA5u44DhgvVnILATaOM_7TAp-vXatL2U',
63+
appId: '1:904342392027:ios:4a2e611a4843f6df2ad0fe',
64+
messagingSenderId: '904342392027',
65+
projectId: 'fe-community-dev',
66+
storageBucket: 'fe-community-dev.appspot.com',
67+
iosClientId:
68+
'904342392027-q5sb99te7uc07m0td6lg8f9kfo4cbohg.apps.googleusercontent.com',
69+
iosBundleId: 'dev.flutterexplained.community-app.dev',
70+
);
71+
}

lib/main_development.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import 'package:community_app/app/app.dart';
22
import 'package:community_app/bootstrap.dart';
33

44
void main() {
5-
bootstrap(() => const App());
5+
bootstrap(() => const App(), Environment.dev);
66
}

lib/main_production.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import 'package:community_app/app/app.dart';
22
import 'package:community_app/bootstrap.dart';
33

44
void main() {
5-
bootstrap(() => const App());
5+
bootstrap(() => const App(), Environment.prod);
66
}

lib/main_staging.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import 'package:community_app/app/app.dart';
22
import 'package:community_app/bootstrap.dart';
33

44
void main() {
5-
bootstrap(() => const App());
5+
bootstrap(() => const App(), Environment.staging);
66
}

0 commit comments

Comments
 (0)