Refactor application package structure and update Firebase iOS bundle IDs for different environments.

This commit is contained in:
Faris Armoush
2025-07-13 12:37:53 +03:00
parent e1b0d56cfd
commit c4fa2256f0
9 changed files with 18 additions and 15 deletions

View File

@ -14,7 +14,7 @@
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:allowBackup="false"> android:allowBackup="false">
<activity <activity
android:name="com.example.syncrow_app.MainActivity" android:name="com.syncrow.mobile.MainActivity"
android:exported="true" android:exported="true"
android:launchMode="singleTop" android:launchMode="singleTop"
android:theme="@style/LaunchTheme" android:theme="@style/LaunchTheme"

View File

@ -1,4 +1,4 @@
package com.example.syncrow_application package com.syncrow.mobile
import io.flutter.embedding.android.FlutterActivity import io.flutter.embedding.android.FlutterActivity

View File

@ -17,8 +17,7 @@ import 'package:syncrow_app/firebase_options_staging.dart' as staging;
/// ); /// );
/// ``` /// ```
class DefaultFirebaseOptions { class DefaultFirebaseOptions {
static FirebaseOptions get currentPlatform { static FirebaseOptions currentPlatform(String flavor) {
const flavor = String.fromEnvironment('flavor');
if (kIsWeb) { if (kIsWeb) {
throw UnsupportedError( throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for web - ' 'DefaultFirebaseOptions have not been configured for web - '
@ -30,11 +29,12 @@ class DefaultFirebaseOptions {
return dev.DefaultFirebaseOptions.currentPlatform; return dev.DefaultFirebaseOptions.currentPlatform;
case 'staging': case 'staging':
return staging.DefaultFirebaseOptions.currentPlatform; return staging.DefaultFirebaseOptions.currentPlatform;
case 'prod': case 'production':
return prod.DefaultFirebaseOptions.currentPlatform; return prod.DefaultFirebaseOptions.currentPlatform;
default: default:
throw UnsupportedError( throw UnsupportedError(
'DefaultFirebaseOptions are not supported for this flavor.', 'DefaultFirebaseOptions have not been configured for web - '
'you can reconfigure this by running the FlutterFire CLI again.',
); );
} }
} }

View File

@ -73,6 +73,6 @@ class DefaultFirebaseOptions {
projectId: 'syncrow-prod-79446', projectId: 'syncrow-prod-79446',
databaseURL: 'https://syncrow-staging-79446.asia-southeast1.firebasedatabase.app/', databaseURL: 'https://syncrow-staging-79446.asia-southeast1.firebasedatabase.app/',
storageBucket: 'syncrow-prod-79446.firebasestorage.app', storageBucket: 'syncrow-prod-79446.firebasestorage.app',
iosBundleId: 'com.syncrow.mobile.dev', iosBundleId: 'com.syncrow.iot.ex.dev',
); );
} }

View File

@ -62,7 +62,7 @@ class DefaultFirebaseOptions {
projectId: 'syncrow-staging', projectId: 'syncrow-staging',
databaseURL: 'https://syncrow-prod-79446.asia-southeast1.firebasedatabase.app/', databaseURL: 'https://syncrow-prod-79446.asia-southeast1.firebasedatabase.app/',
storageBucket: 'syncrow-staging.appspot.com', storageBucket: 'syncrow-staging.appspot.com',
iosBundleId: 'com.example.syncrow.app', iosBundleId: 'com.syncrow.iot.ex',
); );
static const FirebaseOptions web = FirebaseOptions( static const FirebaseOptions web = FirebaseOptions(

View File

@ -73,6 +73,6 @@ class DefaultFirebaseOptions {
projectId: 'syncrow-prod-79446', projectId: 'syncrow-prod-79446',
databaseURL: 'https://syncrow-staging-79446.asia-southeast1.firebasedatabase.app/', databaseURL: 'https://syncrow-staging-79446.asia-southeast1.firebasedatabase.app/',
storageBucket: 'syncrow-prod-79446.firebasestorage.app', storageBucket: 'syncrow-prod-79446.firebasestorage.app',
iosBundleId: 'com.syncrow.mobile.staging', iosBundleId: 'com.syncrow.iot.ex.staging',
); );
} }

View File

@ -42,7 +42,8 @@ void main() {
initialSetup(); initialSetup();
await Firebase.initializeApp( await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform, options: DefaultFirebaseOptions.currentPlatform('production'),
name: 'syncrow_app',
); );
//final SharedPreferences prefs = await SharedPreferences.getInstance(); //final SharedPreferences prefs = await SharedPreferences.getInstance();

View File

@ -40,7 +40,8 @@ void main() {
initialSetup(); initialSetup();
await Firebase.initializeApp( await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform, options: DefaultFirebaseOptions.currentPlatform('dev'),
name: 'syncrow_app',
); );
//final SharedPreferences prefs = await SharedPreferences.getInstance(); //final SharedPreferences prefs = await SharedPreferences.getInstance();

View File

@ -5,11 +5,11 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:permission_handler/permission_handler.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/services/locator.dart';
import 'package:syncrow_app/utils/bloc_observer.dart'; import 'package:syncrow_app/utils/bloc_observer.dart';
import 'package:syncrow_app/utils/helpers/localization_helpers.dart'; import 'package:syncrow_app/utils/helpers/localization_helpers.dart';
import 'firebase_options.dart';
import 'my_app.dart'; import 'my_app.dart';
void main() { void main() {
@ -40,7 +40,8 @@ void main() {
initialSetup(); initialSetup();
await Firebase.initializeApp( await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform, options: DefaultFirebaseOptions.currentPlatform('staging'),
name: 'syncrow_app',
); );
//final SharedPreferences prefs = await SharedPreferences.getInstance(); //final SharedPreferences prefs = await SharedPreferences.getInstance();