firebase prod setup and flavors enhancement.

This commit is contained in:
Faris Armoush
2025-07-13 11:49:58 +03:00
parent 743d6cc5c6
commit e1b0d56cfd
26 changed files with 939 additions and 321 deletions
+41
View File
@@ -0,0 +1,41 @@
// File generated by FlutterFire CLI.
// ignore_for_file: type=lint
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:syncrow_app/firebase_options_dev.dart' as dev;
import 'package:syncrow_app/firebase_options_prod.dart' as prod;
import 'package:syncrow_app/firebase_options_staging.dart' as staging;
/// 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 {
const flavor = String.fromEnvironment('flavor');
if (kIsWeb) {
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for web - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
}
switch (flavor) {
case 'dev':
return dev.DefaultFirebaseOptions.currentPlatform;
case 'staging':
return staging.DefaultFirebaseOptions.currentPlatform;
case 'prod':
return prod.DefaultFirebaseOptions.currentPlatform;
default:
throw UnsupportedError(
'DefaultFirebaseOptions are not supported for this flavor.',
);
}
}
}
+28 -24
View File
@@ -1,19 +1,20 @@
// File generated by FlutterFire CLI.
// ignore_for_file: type=lint
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform;
import 'package:flutter/foundation.dart'
show defaultTargetPlatform, kIsWeb, TargetPlatform;
/// Default [FirebaseOptions] for use with your Firebase apps.
///
/// Example:
/// ```dart
/// import 'firebase_options.dart';
/// import 'firebase_options_dev.dart';
/// // ...
/// await Firebase.initializeApp(
/// options: DefaultFirebaseOptions.currentPlatform,
/// );
/// ```
class DefaultFirebaseOptionsDev {
class DefaultFirebaseOptions {
static FirebaseOptions get currentPlatform {
if (kIsWeb) {
return web;
@@ -45,30 +46,33 @@ class DefaultFirebaseOptionsDev {
}
}
static const FirebaseOptions web = FirebaseOptions(
apiKey: 'AIzaSyDgq5ywsnFVbbQO-Xz1Z4sR5bBcuiDaS9g',
appId: '1:255001682464:web:a03e2d6214c13101561245',
messagingSenderId: '255001682464',
projectId: 'syncrow-prod-79446',
authDomain: 'syncrow-prod-79446.firebaseapp.com',
databaseURL: 'https://syncrow-staging-79446.asia-southeast1.firebasedatabase.app/',
storageBucket: 'syncrow-prod-79446.firebasestorage.app',
measurementId: 'G-1850Q89RMK',
);
static const FirebaseOptions android = FirebaseOptions(
apiKey: 'AIzaSyA5qOErxdm0zJmoHIB0TixfebYEsNRpwV0',
appId: '1:427332280600:android:bb6047adeeb80fb00c7e6d',
messagingSenderId: '427332280600',
projectId: 'test2-8a3d2',
storageBucket: 'test2-8a3d2.appspot.com',
apiKey: 'AIzaSyARJ5Wx2Uf8sbmb-AHB8WVfFwEFzrCIOKY',
appId: '1:255001682464:android:55ba58e8297b3cab561245',
messagingSenderId: '255001682464',
projectId: 'syncrow-prod-79446',
databaseURL: 'https://syncrow-staging-79446.asia-southeast1.firebasedatabase.app/',
storageBucket: 'syncrow-prod-79446.firebasestorage.app',
);
static const FirebaseOptions ios = FirebaseOptions(
apiKey: 'AIzaSyABnpH6yo2RRjtkp4PlvtK84hKwRm2DhBw',
appId: '1:427332280600:ios:373a65cce55a3af40c7e6d',
messagingSenderId: '427332280600',
projectId: 'test2-8a3d2',
storageBucket: 'test2-8a3d2.appspot.com',
iosBundleId: 'com.example.syncrowApp',
);
static const FirebaseOptions web = FirebaseOptions(
apiKey: 'AIzaSyCVEvKsJYzhWDFM-9Od68FE0nPpP933st0',
appId: '1:427332280600:web:ad50516a87a35a1a0c7e6d',
messagingSenderId: '427332280600',
projectId: 'test2-8a3d2',
authDomain: 'test2-8a3d2.firebaseapp.com',
storageBucket: 'test2-8a3d2.appspot.com',
measurementId: 'G-Z1RTTTV5H9',
apiKey: 'AIzaSyDeUWSHReSROpDbENGr--F49DH4VRzVM5A',
appId: '1:255001682464:ios:8a57c70f7f16f785561245',
messagingSenderId: '255001682464',
projectId: 'syncrow-prod-79446',
databaseURL: 'https://syncrow-staging-79446.asia-southeast1.firebasedatabase.app/',
storageBucket: 'syncrow-prod-79446.firebasestorage.app',
iosBundleId: 'com.syncrow.mobile.dev',
);
}
+5 -4
View File
@@ -1,7 +1,8 @@
// File generated by FlutterFire CLI.
// ignore_for_file: type=lint
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform;
import 'package:flutter/foundation.dart'
show defaultTargetPlatform, kIsWeb, TargetPlatform;
/// Default [FirebaseOptions] for use with your Firebase apps.
///
@@ -13,7 +14,7 @@ import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, Tar
/// options: DefaultFirebaseOptions.currentPlatform,
/// );
/// ```
class DefaultFirebaseOptionsStaging {
class DefaultFirebaseOptions {
static FirebaseOptions get currentPlatform {
if (kIsWeb) {
return web;
@@ -59,7 +60,7 @@ class DefaultFirebaseOptionsStaging {
appId: '1:786692570726:ios:455a6fcff77e130f17b7a7',
messagingSenderId: '786692570726',
projectId: 'syncrow-staging',
databaseURL: 'https://syncrow-staging-default-rtdb.firebaseio.com',
databaseURL: 'https://syncrow-prod-79446.asia-southeast1.firebasedatabase.app/',
storageBucket: 'syncrow-staging.appspot.com',
iosBundleId: 'com.example.syncrow.app',
);
@@ -70,7 +71,7 @@ class DefaultFirebaseOptionsStaging {
messagingSenderId: '786692570726',
projectId: 'syncrow-staging',
authDomain: 'syncrow-staging.firebaseapp.com',
databaseURL: 'https://syncrow-staging-default-rtdb.firebaseio.com',
databaseURL: 'https://syncrow-prod-79446.asia-southeast1.firebasedatabase.app/',
storageBucket: 'syncrow-staging.appspot.com',
measurementId: 'G-CZ3J3G6LMQ',
);
+78
View File
@@ -0,0 +1,78 @@
// File generated by FlutterFire CLI.
// ignore_for_file: type=lint
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_staging.dart';
/// // ...
/// await Firebase.initializeApp(
/// options: DefaultFirebaseOptions.currentPlatform,
/// );
/// ```
class DefaultFirebaseOptions {
static FirebaseOptions get currentPlatform {
if (kIsWeb) {
return web;
}
switch (defaultTargetPlatform) {
case TargetPlatform.android:
return android;
case TargetPlatform.iOS:
return ios;
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: 'AIzaSyDgq5ywsnFVbbQO-Xz1Z4sR5bBcuiDaS9g',
appId: '1:255001682464:web:a03e2d6214c13101561245',
messagingSenderId: '255001682464',
projectId: 'syncrow-prod-79446',
authDomain: 'syncrow-prod-79446.firebaseapp.com',
databaseURL: 'https://syncrow-prod-79446-default-rtdb.firebaseio.com',
storageBucket: 'syncrow-prod-79446.firebasestorage.app',
measurementId: 'G-1850Q89RMK',
);
static const FirebaseOptions android = FirebaseOptions(
apiKey: 'AIzaSyARJ5Wx2Uf8sbmb-AHB8WVfFwEFzrCIOKY',
appId: '1:255001682464:android:ed8920a3067fb40a561245',
messagingSenderId: '255001682464',
projectId: 'syncrow-prod-79446',
databaseURL: 'https://syncrow-staging-79446.asia-southeast1.firebasedatabase.app/',
storageBucket: 'syncrow-prod-79446.firebasestorage.app',
);
static const FirebaseOptions ios = FirebaseOptions(
apiKey: 'AIzaSyDeUWSHReSROpDbENGr--F49DH4VRzVM5A',
appId: '1:255001682464:ios:41b89a7702b75227561245',
messagingSenderId: '255001682464',
projectId: 'syncrow-prod-79446',
databaseURL: 'https://syncrow-staging-79446.asia-southeast1.firebasedatabase.app/',
storageBucket: 'syncrow-prod-79446.firebasestorage.app',
iosBundleId: 'com.syncrow.mobile.staging',
);
}
+9 -3
View File
@@ -1,14 +1,16 @@
import 'dart:async';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:syncrow_app/firebase_options_prod.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:syncrow_app/firebase_options.dart';
import 'package:syncrow_app/services/locator.dart';
import 'package:syncrow_app/utils/bloc_observer.dart';
import 'package:syncrow_app/utils/helpers/localization_helpers.dart';
import 'my_app.dart';
import 'my_app.dart';
const String buildNumber = '1.0.30+18';
@@ -25,6 +27,10 @@ void main() {
// HttpOverrides.global = MyHttpOverrides();
WidgetsFlutterBinding.ensureInitialized();
if (await Permission.nearbyWifiDevices.request().isGranted) {
// Permission is granted
}
//license for the font
// LicenseRegistry.addLicense(() async* {
// final license =
@@ -36,7 +42,7 @@ void main() {
initialSetup();
await Firebase.initializeApp(
options: DefaultFirebaseOptionsStaging.currentPlatform,
options: DefaultFirebaseOptions.currentPlatform,
);
//final SharedPreferences prefs = await SharedPreferences.getInstance();
+9 -2
View File
@@ -1,12 +1,15 @@
import 'dart:async';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:syncrow_app/firebase_options_dev.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:syncrow_app/firebase_options.dart';
import 'package:syncrow_app/services/locator.dart';
import 'package:syncrow_app/utils/bloc_observer.dart';
import 'package:syncrow_app/utils/helpers/localization_helpers.dart';
import 'my_app.dart';
void main() {
@@ -22,6 +25,10 @@ void main() {
// HttpOverrides.global = MyHttpOverrides();
WidgetsFlutterBinding.ensureInitialized();
if (await Permission.nearbyWifiDevices.request().isGranted) {
// Permission is granted
}
//license for the font
// LicenseRegistry.addLicense(() async* {
// final license =
@@ -33,7 +40,7 @@ void main() {
initialSetup();
await Firebase.initializeApp(
options: DefaultFirebaseOptionsDev.currentPlatform,
options: DefaultFirebaseOptions.currentPlatform,
);
//final SharedPreferences prefs = await SharedPreferences.getInstance();
+56
View File
@@ -0,0 +1,56 @@
import 'dart:async';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:syncrow_app/firebase_options_staging.dart';
import 'package:syncrow_app/services/locator.dart';
import 'package:syncrow_app/utils/bloc_observer.dart';
import 'package:syncrow_app/utils/helpers/localization_helpers.dart';
import 'my_app.dart';
void main() {
//to observe the state of the blocs in the output console
Bloc.observer = MyBlocObserver();
//to catch all the errors in the app and send them to firebase
runZonedGuarded(() async {
//to load the environment variables
// const environment = String.fromEnvironment('FLAVOR', defaultValue: 'prod');
await dotenv.load(fileName: '.env.staging');
// //this is to make the app work with the self-signed certificate
// HttpOverrides.global = MyHttpOverrides();
WidgetsFlutterBinding.ensureInitialized();
if (await Permission.nearbyWifiDevices.request().isGranted) {
// Permission is granted
}
//license for the font
// LicenseRegistry.addLicense(() async* {
// final license =
// await rootBundle.loadString('assets/fonts/roboto/LICENSE.txt');
// yield LicenseEntryWithLineBreaks(['google_fonts'], license);
// });
//to initialize the locator
initialSetup();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
//final SharedPreferences prefs = await SharedPreferences.getInstance();
//to save the locale in the shared preferences
await LocalizationService.saveLocale(const Locale("en", "AE"));
final savedLocale = await LocalizationService.savedLocale();
runApp(MyApp(savedLocale));
}, (error, stackTrace) {
// FirebaseCrashlytics.instance.recordError(error, stackTrace, fatal: true);
});
}
+1 -1
View File
@@ -46,7 +46,7 @@ class MyApp extends StatelessWidget {
scaffoldMessengerKey: NavigationService.snackbarKey,
debugShowCheckedModeBanner: false,
color: ColorsManager.primaryColor,
title: 'Syncrow App',
title: 'SyncOS',
onGenerateRoute: router.Router.generateRoute,
initialRoute: Routes.splash,
themeMode: ThemeMode.system,
+1 -1
View File
@@ -12,7 +12,7 @@ import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
abstract class Constants {
static const String appName = "Syncrow App";
static const String appName = "SyncOS";
static const String languageCode = "en";