FlutterToast
FlutterToast copied to clipboard
fix: Demo Unhandled Exception: Null check operator used on a null value Close #29
[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]
-
Toast.showneed invokeToastView.createViewwhich needoverlayStatefrom its ancestor widget. - The official demo initial the
ToastContextinMyApp.build, which ancestor element isRenderObjectToWidgetElement -> StatelessElement,soOverlay.ofcan't findoverlayState. - Meanwhile the
MaterialAppalready insert anoverlayStatefor 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)
