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

Error: null check operator used on a null value #338

Closed
proninyaroslav opened this issue Aug 29, 2021 · 2 comments
Closed

Error: null check operator used on a null value #338

proninyaroslav opened this issue Aug 29, 2021 · 2 comments

Comments

@proninyaroslav
Copy link

proninyaroslav commented Aug 29, 2021

OS: Linux
Flutter Version: 2.2.3
Package version: 8.0.8

This happened when I showed the same toast twice and closed the modal window (AlertDialog):

Null check operator used on a null value
#0      FToast._showOverlay (package:fluttertoast/fluttertoast.dart:148)
#1      FToast.removeCustomToast (package:fluttertoast/fluttertoast.dart:164)
#2      FToast._showOverlay.<anonymous closure>.<anonymous closure> (package:fluttertoast/fluttertoast.dart:152)
#3      new Future.delayed.<anonymous closure> (dart:async/future.dart:315)
#4      _rootRun (dart:async/zone.dart:1346)
#5      _CustomZone.run (dart:async/zone.dart:1258)
#6      _CustomZone.runGuarded (dart:async/zone.dart:1162)
#7      _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202)
#8      _rootRun (dart:async/zone.dart:1354)
#9      _CustomZone.run (dart:async/zone.dart:1258)
#10     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1186)
#11     TickerFuture.whenCompleteOrCancel.thunk (package:flutter/src/scheduler/ticker.dart:407)
#12     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:395)
#13     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426)
#14     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184)

Example:

Toast.of(context).show(text: 'Text');
@shadabunique
Copy link
Contributor

Fixed in PR #346

@shaoting0730
Copy link

Or was it unsuccessful?
Flutter Version: 2.2.3
Package version: 8.0.8

  late FToast fToast;
....
  @override
  void initState() {
    super.initState();

    BuildContext context = navigatorKey.currentState!.context;

    fToast = FToast();
    fToast.init(context);
  }
...
 fToast.showToast(
        child: toast,
        gravity: ToastGravity.CENTER,
        toastDuration: Duration(seconds: 2),
      );

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

No branches or pull requests

4 participants