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

fix: Demo Unhandled Exception: Null check operator used on a null value Close #29 #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jixiaoyong
Copy link

[PROBLEM]

The official demo will throw the error Unhandled Exception: Null check operator used on a null value when showing toast.

see: Issue#29

[REASON]

  1. Toast.show need invoke ToastView.createView which need overlayState from its ancestor widget.
  2. The official demo initial the ToastContext in MyApp.build, which ancestor element is RenderObjectToWidgetElement -> StatelessElement ,so Overlay.of can't find overlayState.
  3. Meanwhile the MaterialApp already insert an overlayState for us

[SOLUTION]

Use the context of MyHomePage instead of MyApp.

[TEST]

Work with Flutter (Channel stable, 2.10.5, on Microsoft Windows [Version 10.0.19043.1766], locale en-US)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant