Skip to content

[firebase_messaging] Flutter throws NoSuchMethod error when hot restarting (Please read description) #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ThinkDigitalSoftware opened this issue Sep 24, 2019 · 3 comments

Comments

@ThinkDigitalSoftware
Copy link

Error thrown is NoSuchMethodError: The method 'add' was called on null. Receiver: null Tried calling: add(Instance of 'QuerySnapshot'):

I don't know why the error is happening, but I have traced down the reason. I'm assuming that my device never deregisters as an observer before it's hot restarted and it contributes to the issue. The attached video can explain the issue better than I can. Please ask for clarification as I'm unable to duplicate it since I don't understand it fully enough.
Video
In cloud_firestore-0.9.7/lib/src/firestore.dart

class Firestore {
  Firestore({FirebaseApp app}) : app = app ?? FirebaseApp.instance {
    if (_initialized) return;
    channel.setMethodCallHandler((MethodCall call) async {
      if (call.method == 'QuerySnapshot') {
        final QuerySnapshot snapshot = QuerySnapshot._(call.arguments, this);

       // THIS IS WHERE THE ERROR OCCURS👇🏾
        _queryObservers[call.arguments['handle']].add(snapshot);
      } else if (call.method == 'DocumentSnapshot') {
        final DocumentSnapshot snapshot = DocumentSnapshot._(
          call.arguments['path'],
          _asStringKeyedMap(call.arguments['data']),
          this,
        );

Variables:
call.arguments['handle'] -> 7

_queryObservers (I just realized that this list starts at a higher number after I hot restart). This must be the cause.
_queryObservers

@iapicca iapicca added the type: bug Something isn't working label Oct 21, 2019
@iapicca
Copy link

iapicca commented Oct 21, 2019

Hi @ThinkDigitalSoftware
could you please provide your flutter doctor -v
and your flutter run --verbose.
Thank you

@iapicca iapicca added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Oct 21, 2019
@ThinkDigitalSoftware
Copy link
Author

Sorry, this was some time ago, my version has changed since then.

@iapicca iapicca changed the title Flutter throws NoSuchMethod error when hot restarting (Please read description) [firebase_messaging] Flutter throws NoSuchMethod error when hot restarting (Please read description) Oct 23, 2019
@iapicca
Copy link

iapicca commented Oct 23, 2019

Hi @ThinkDigitalSoftware
given your last message I feel safe to close this issue,
if you disagree please write in the comments
and I will reopen it.
Thank you
#125

@iapicca iapicca closed this as completed Oct 23, 2019
@iapicca iapicca removed blocked: customer-response Waiting for customer response, e.g. more information was requested. type: bug Something isn't working labels Oct 24, 2019
@firebase firebase locked and limited conversation to collaborators Aug 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants