Skip to content
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

NoSuchMethodError: The method 'hide' was called on null. #4

Closed
ryanhz opened this issue May 14, 2019 · 9 comments
Closed

NoSuchMethodError: The method 'hide' was called on null. #4

ryanhz opened this issue May 14, 2019 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@ryanhz
Copy link

ryanhz commented May 14, 2019

Thank you for such a fantastic package. I spot an exception:

NoSuchMethodError: The method 'hide' was called on null.
Receiver: null
Tried calling: hide()
#0 NotificationEntry.dismiss (package:overlay_support/src/overlay_entry.dart:22)
#1 showOverlay.. (package:overlay_support/src/overlay.dart:43)
#2 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:988)
#3 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleBeginFrame. (package:flutter/src/scheduler/binding.dart:904)

@boyan01 boyan01 self-assigned this May 15, 2019
@boyan01 boyan01 added the bug Something isn't working label May 15, 2019
@boyan01
Copy link
Owner

boyan01 commented May 15, 2019

Which lib and flutter version are you using?

@Goolpe
Copy link

Goolpe commented May 15, 2019

I have the same issue on
overlay_support: 0.1.0
flutter: 1.5.8

@boyan01
Copy link
Owner

boyan01 commented May 15, 2019

i will try to figure out the cause, but it will be very helpful if you can provide specific code .

@Goolpe
Copy link

Goolpe commented May 15, 2019

if I use separate funcs:

NotificationEntry entry;
Column(
  mainAxisAlignment: MainAxisAlignment.center,
  children: <Widget>[
    RaisedButton(
      color: Colors.red,
      child: Text('show'),
      onPressed: (){
        entry = showSimpleNotification(context,
          const Text('Load video'),
          elevation: 0,
          autoDismiss: false);
      },
    ),
    RaisedButton(
      color: Colors.green,
      child: Text('dismiss'),
      onPressed: (){
        entry.dismiss();
      },
    )
  ]
)

works fine, but if in one function like:

NotificationEntry entry;
RaisedButton(
  color: Colors.red,
  child: Text('show'),
  onPressed: (){
    entry = showSimpleNotification(context,
      const Text('Load video'),
      elevation: 0,
      autoDismiss: false);
    entry.dismiss();
  },
),

get error

@boyan01
Copy link
Owner

boyan01 commented May 15, 2019

i think this should be a wrong use case, because we should not dismiss notification immediately when we popup a notification into screen.

but this also should be a problem, I only add protect logic for autoDismiss :

WidgetsBinding.instance

thanks for the information, i will fix this in next version.

@ryanhz
Copy link
Author

ryanhz commented May 15, 2019

Sorry, coming back late.

How I use:

First, because I used another library before, so here is a wrap function:

void showToast({@required BuildContext context, String title, @required String message, Duration duration = const Duration(seconds: 3)}) {
    toast(context, message, duration: duration);
}

Then use it like:

showToast(message: "doing something successfully", duration: Duration(seconds: 2));
Navigator.pop(context, true);

So I think the Navigator.pop(context, true); should screw the status of the overlay.

@boyan01
Copy link
Owner

boyan01 commented May 16, 2019

in normally use case, Navigator.pop does not affect the status of Overlay, because the Overlay is a application level Widget.

is that you used one of Overlay,WidgetsApp or MaterialApp widget in a single page?

@ryanhz
Copy link
Author

ryanhz commented May 16, 2019

So that is weird. I use MaterialApp as root widget tree.

@boyan01
Copy link
Owner

boyan01 commented May 16, 2019

maybe i found the cause, i guess you used ReorderableListView or something wrapped a Overlay widget.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants