Search code examples
flutterfirebasegoogle-cloud-firestoreflutter-ios

Flutterfire Firestore throws "Instance of 'OA' is null" on listen


I load data from Firestore into my Flutter app. For that I use the Flutterfire Firestore ODM. Everything works fine on the iOS Simulators and the release android app. But on the release iOS app I get the following error with no further explanation:

Instance of 'OA'. Error thrown null.

Other requests work just fine.

I cannot figure out what is wrong and cannot find an answer to this online. In Firebase Crashlytics I get to see this:

Non-fatal Exception: FlutterError
0  ???                            0x0 (null).    #00 abs 0 _kDartIsolateSnapshotInstructions+0x167a27
1  ???                            0x0 (null).    #01 abs 0 _kDartIsolateSnapshotInstructions+0x167a87
2  ???                            0x0 (null).    #02 abs 0 _kDartIsolateSnapshotInstructions+0x169b9b
3  ???                            0x0 (null).    #03 abs 0 _kDartIsolateSnapshotInstructions+0x1699bb
4  ???                            0x0 (null).    #04 abs 0 _kDartIsolateSnapshotInstructions+0x16995f
(this continues until line 59)

My Code:

FirestoreBuilder(
  ref: context.read<VacationRepository>().getDashboardVactions(),
  builder: (context, AsyncSnapshot<VacationEntityQuerySnapshot> snapshot, child) {
    if (snapshot.connectionState == ConnectionState.waiting) {
      return ReuseableWidgets.linearSpinner;
    }

    if (snapshot.hasError) {
      FirebaseCrashlytics.instance.recordError(
        snapshot.error,
        snapshot.stackTrace,
      );
      // ^ this is where the error is caught
      return ReuseableWidgets.somethingWentWrong;
    }
...

and getDashboardVacations() is:

FirestoreListenable<VacationEntityQuerySnapshot> getDashboardVactions() {
  String currentUser = _authenticationRepository.currentUser.id;
  return vacationsRef.whereMembers(arrayContainsAny: [currentUser]);
}

Solution

  • I do not know what or how it happens, but when obfuscating the build this feature broke.

    So just remove the --obfuscate map and it works again.