inconsistent data type error while fetching data from Firestore using Flutter

Viewed 54

I am new to Flutter as well as Firestore. I will try to make sense at my best for problem I've came across while using Flutter with Firestore.

Code:

  QuerySnapshot<Map<String, dynamic>> user = await checkUserExistenceInFireStore('uid', getUid);
  if(user.docs.isNotEmpty){
    for (var element in user.docs) {
      // Here I have been forced by Flutter to use this for integer
      SharedPreferencesHelper.setBlocked(int.parse(element.data()['appDisabled']));
      // Instead this
      SharedPreferencesHelper.setBlocked(element.data()['appDisabled']);
    }
  }

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: type 'String' is not a subtype of type 'int'

Surprisingly, I've been using element.data()['appDisabled'] all the time without any problem for integers until now.

Okay, I can live with it and can use int.parse(element.data()['appDisabled']) but it gives me another problem. App works fine in debug mode but in release mode stops working.

Screenshot:

enter image description here

Please help. Thanks in advance.

0 Answers
Related