My main.dart
:
void main() async {
await preinit();
await di<FirebaseAuthService>().useEmulator();
await di<FirebaseFunctionsService>().useEmulator();
await initApp();
}
Part of my FirebaseAuthService
:
@singleton
class FirebaseAuthService {
final FirebaseAuth _service;
FirebaseAuthService(FirebaseCoreService firebaseCoreService)
: _service = FirebaseAuth.instanceFor(app: firebaseCoreService.app);
}
Part of my FirebaseFunctionsService
:
@injectable
class FirebaseFunctionsService {
final FirebaseFunctions _service;
FirebaseFunctionsService(FirebaseCoreService firebaseCoreService)
: _service = FirebaseFunctions.instanceFor(app: firebaseCoreService.app);
}
My FirebaseCoreService
:
@singleton
class FirebaseCoreService {
final FirebaseApp _app;
FirebaseApp get app => _app;
FirebaseCoreService._(this._app);
@factoryMethod
static Future<FirebaseCoreService> create() async {
final app = await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
if (!kIsWeb) {
await FirebaseCrashlytics.instance
.setCrashlyticsCollectionEnabled(!kDebugMode);
}
return FirebaseCoreService._(app);
}
}
At Firebase.initializeApp
that is called right after preinit()
in main.dart
, I get the following error:
"Error: Invalid argument(s): object cannot be a num, string, bool, or null
at Object.throw_ [as throw] (http://localhost:50958/dart_sdk.js:5080:11)
at JsObject.fromBrowserObject (http://localhost:50958/dart_sdk.js:61852:19)
at get [_ignoredServiceScripts] (http://localhost:50958/packages/firebase_core_web/firebase_core_web.dart.lib.js:147:35)
at firebase_core_web.FirebaseCoreWeb.new._initializeCore (http://localhost:50958/packages/firebase_core_web/firebase_core_web.dart.lib.js:182:27)
at _initializeCore.next (<anonymous>)
at runBody (http://localhost:50958/dart_sdk.js:40660:34)
at Object._async [as async] (http://localhost:50958/dart_sdk.js:40691:7)
at [_initializeCore] (http://localhost:50958/packages/firebase_core_web/firebase_core_web.dart.lib.js:177:20)
at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:50958/packages/firebase_core_web/firebase_core_web.dart.lib.js:199:36)
at initializeApp.next (<anonymous>)
at runBody (http://localhost:50958/dart_sdk.js:40660:34)
at Object._async [as async] (http://localhost:50958/dart_sdk.js:40691:7)
at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:50958/packages/firebase_core_web/firebase_core_web.dart.lib.js:198:20)
at initializeApp (http://localhost:50958/packages/firebase_core/firebase_core.dart.lib.js:105:59)
at initializeApp.next (<anonymous>)
at runBody (http://localhost:50958/dart_sdk.js:40660:34)
at Object._async [as async] (http://localhost:50958/dart_sdk.js:40691:7)
at Firebase.initializeApp (http://localhost:50958/packages/firebase_core/firebase_core.dart.lib.js:104:20)
at create (http://localhost:50958/packages/wa_flutter_questionnaire/data/firebase/firebase_core_service.dart.lib.js:26:49)
at create.next (<anonymous>)
at runBody (http://localhost:50958/dart_sdk.js:40660:34)
at Object._async [as async] (http://localhost:50958/dart_sdk.js:40691:7)
at FirebaseCoreService.create (http://localhost:50958/packages/wa_flutter_questionnaire/data/firebase/firebase_core_service.dart.lib.js:25:20)
at http://localhost:50958/packages/wa_flutter_questionnaire/domain/theme_manager.dart.lib.js:1903:130
at get_it_helper.GetItHelper.new.singletonAsync (http://localhost:50958/packages/injectable/src/get_it_helper.dart.lib.js:117:18)
at $36initGetIt (http://localhost:50958/packages/wa_flutter_questionnaire/domain/theme_manager.dart.lib.js:1903:16)
at $36initGetIt.next (<anonymous>)
at runBody (http://localhost:50958/dart_sdk.js:40660:34)
at Object._async [as async] (http://localhost:50958/dart_sdk.js:40691:7)
at Object.$36initGetIt [as $initGetIt] (http://localhost:50958/packages/wa_flutter_questionnaire/domain/theme_manager.dart.lib.js:1900:18)
at configureDependencies (http://localhost:50958/packages/wa_flutter_questionnaire/domain/theme_manager.dart.lib.js:1918:32)
at configureDependencies.next (<anonymous>)
at runBody (http://localhost:50958/dart_sdk.js:40660:34)
at Object._async [as async] (http://localhost:50958/dart_sdk.js:40691:7)
at Object.configureDependencies (http://localhost:50958/packages/wa_flutter_questionnaire/domain/theme_manager.dart.lib.js:1917:18)
at preinit (http://localhost:50958/packages/wa_flutter_questionnaire/main.dart.lib.js:55:16)
at preinit.next (<anonymous>)
at runBody (http://localhost:50958/dart_sdk.js:40660:34)
at Object._async [as async] (http://localhost:50958/dart_sdk.js:40691:7)
at Object.preinit (http://localhost:50958/packages/wa_flutter_questionnaire/main.dart.lib.js:52:18)
at main$ (http://localhost:50958/packages/wa_flutter_questionnaire/main_local.dart.lib.js:18:18)
at main$.next (<anonymous>)
at runBody (http://localhost:50958/dart_sdk.js:40660:34)
at Object._async [as async] (http://localhost:50958/dart_sdk.js:40691:7)
at main$ (http://localhost:50958/packages/wa_flutter_questionnaire/main_local.dart.lib.js:17:18)
at http://localhost:50958/web_entrypoint.dart.lib.js:37:33
at Object._checkAndCall (http://localhost:50958/dart_sdk.js:5279:16)
at Object.dcall (http://localhost:50958/dart_sdk.js:5284:17)
at http://localhost:50958/dart_sdk.js:140291:18
at Generator.next (<anonymous>)
at http://localhost:50958/dart_sdk.js:40641:33
at _RootZone.runUnary (http://localhost:50958/dart_sdk.js:40511:59)
at _FutureListener.thenAwait.handleValue (http://localhost:50958/dart_sdk.js:35438:29)
at handleValueCallback (http://localhost:50958/dart_sdk.js:35999:49)
at _Future._propagateToListeners (http://localhost:50958/dart_sdk.js:36037:17)
at [_completeWithValue] (http://localhost:50958/dart_sdk.js:35872:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:50958/dart_sdk.js:35906:35)
at Object._microtaskLoop (http://localhost:50958/dart_sdk.js:40778:13)
at _startMicrotaskLoop (http://localhost:50958/dart_sdk.js:40784:13)
at http://localhost:50958/dart_sdk.js:36261:9"
My ignoredServiceScripts
in part of firebase_core_web
:
List<String> get _ignoredServiceScripts {
try {
JsObject ignored =
JsObject.fromBrowserObject('flutterfire_ignore_scripts');
if (ignored is Iterable) {
return (ignored as Iterable)
.map((e) => e.toString())
.toList(growable: false);
}
} catch (e) {
// Noop
}
return [];
}
I don't get this error while running my app on iOS, for example. Can you please help?
Update:
I changed JsObject.fromBrowserObject('flutterfire_ignore_scripts')
to JsObject.fromBrowserObject(context['flutterfire_ignore_scripts'])
, so it doesn't fail with this error anymore, it does fail with another one (both on web, iOS, Android):
"Error: Expected a value of type 'Object', but got one of type 'Null'
at Object.throw_ [as throw] (http://localhost:59214/dart_sdk.js:5080:11)
at Object.castError (http://localhost:59214/dart_sdk.js:5039:15)
at Object.cast [as as] (http://localhost:59214/dart_sdk.js:5356:17)
at Object.as (http://localhost:59214/dart_sdk.js:6603:31)
at get [_ignoredServiceScripts] (http://localhost:59214/packages/firebase_core_web/firebase_core_web.dart.lib.js:147:65)
at firebase_core_web.FirebaseCoreWeb.new._initializeCore (http://localhost:59214/packages/firebase_core_web/firebase_core_web.dart.lib.js:182:27)
at _initializeCore.next (<anonymous>)
at runBody (http://localhost:59214/dart_sdk.js:40660:34)
at Object._async [as async] (http://localhost:59214/dart_sdk.js:40691:7)
at [_initializeCore] (http://localhost:59214/packages/firebase_core_web/firebase_core_web.dart.lib.js:177:20)
at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:59214/packages/firebase_core_web/firebase_core_web.dart.lib.js:199:36)
at initializeApp.next (<anonymous>)
at runBody (http://localhost:59214/dart_sdk.js:40660:34)
at Object._async [as async] (http://localhost:59214/dart_sdk.js:40691:7)
at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:59214/packages/firebase_core_web/firebase_core_web.dart.lib.js:198:20)
at initializeApp (http://localhost:59214/packages/firebase_core/firebase_core.dart.lib.js:105:59)
at initializeApp.next (<anonymous>)
at runBody (http://localhost:59214/dart_sdk.js:40660:34)
at Object._async [as async] (http://localhost:59214/dart_sdk.js:40691:7)
at Firebase.initializeApp (http://localhost:59214/packages/firebase_core/firebase_core.dart.lib.js:104:20)
at create (http://localhost:59214/packages/wa_flutter_questionnaire/data/firebase/firebase_core_service.dart.lib.js:26:49)
at create.next (<anonymous>)
at runBody (http://localhost:59214/dart_sdk.js:40660:34)
at Object._async [as async] (http://localhost:59214/dart_sdk.js:40691:7)
at FirebaseCoreService.create (http://localhost:59214/packages/wa_flutter_questionnaire/data/firebase/firebase_core_service.dart.lib.js:25:20)
at http://localhost:59214/packages/wa_flutter_questionnaire/domain/theme_manager.dart.lib.js:1903:130
at get_it_helper.GetItHelper.new.singletonAsync (http://localhost:59214/packages/injectable/src/get_it_helper.dart.lib.js:117:18)
at $36initGetIt (http://localhost:59214/packages/wa_flutter_questionnaire/domain/theme_manager.dart.lib.js:1903:16)
at $36initGetIt.next (<anonymous>)
at runBody (http://localhost:59214/dart_sdk.js:40660:34)
at Object._async [as async] (http://localhost:59214/dart_sdk.js:40691:7)
at Object.$36initGetIt [as $initGetIt] (http://localhost:59214/packages/wa_flutter_questionnaire/domain/theme_manager.dart.lib.js:1900:18)
at configureDependencies (http://localhost:59214/packages/wa_flutter_questionnaire/domain/theme_manager.dart.lib.js:1918:32)
at configureDependencies.next (<anonymous>)
at runBody (http://localhost:59214/dart_sdk.js:40660:34)
at Object._async [as async] (http://localhost:59214/dart_sdk.js:40691:7)
at Object.configureDependencies (http://localhost:59214/packages/wa_flutter_questionnaire/domain/theme_manager.dart.lib.js:1917:18)
at preinit (http://localhost:59214/packages/wa_flutter_questionnaire/main.dart.lib.js:55:16)
at preinit.next (<anonymous>)
at runBody (http://localhost:59214/dart_sdk.js:40660:34)
at Object._async [as async] (http://localhost:59214/dart_sdk.js:40691:7)
at Object.preinit (http://localhost:59214/packages/wa_flutter_questionnaire/main.dart.lib.js:52:18)
at main$ (http://localhost:59214/packages/wa_flutter_questionnaire/main_local.dart.lib.js:18:18)
at main$.next (<anonymous>)
at runBody (http://localhost:59214/dart_sdk.js:40660:34)
at Object._async [as async] (http://localhost:59214/dart_sdk.js:40691:7)
at main$ (http://localhost:59214/packages/wa_flutter_questionnaire/main_local.dart.lib.js:17:18)
at http://localhost:59214/web_entrypoint.dart.lib.js:37:33
at Object._checkAndCall (http://localhost:59214/dart_sdk.js:5279:16)
at Object.dcall (http://localhost:59214/dart_sdk.js:5284:17)
at http://localhost:59214/dart_sdk.js:140291:18
at Generator.next (<anonymous>)
at http://localhost:59214/dart_sdk.js:40641:33
at _RootZone.runUnary (http://localhost:59214/dart_sdk.js:40511:59)
at _FutureListener.thenAwait.handleValue (http://localhost:59214/dart_sdk.js:35438:29)
at handleValueCallback (http://localhost:59214/dart_sdk.js:35999:49)
at _Future._propagateToListeners (http://localhost:59214/dart_sdk.js:36037:17)
at [_completeWithValue] (http://localhost:59214/dart_sdk.js:35872:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:59214/dart_sdk.js:35906:35)
at Object._microtaskLoop (http://localhost:59214/dart_sdk.js:40778:13)
at _startMicrotaskLoop (http://localhost:59214/dart_sdk.js:40784:13)
at http://localhost:59214/dart_sdk.js:36261:9"