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

'_overlay != null' error #8

Closed
genius1212 opened this issue Mar 17, 2020 · 13 comments
Closed

'_overlay != null' error #8

genius1212 opened this issue Mar 17, 2020 · 13 comments

Comments

@genius1212
Copy link

use EasyLoading.show(status: "loading..."); Error!

error stack:
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: 'package:flutter/src/widgets/overlay.dart': Failed assertion: line 132 pos 12: '_overlay != null': is not true.
#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:42:39)
#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:38:5)
#2 OverlayEntry.remove (package:flutter/src/widgets/overlay.dart:132:12)
#3 EasyLoading._remove (package:flutter_easyloading/src/easy_loading.dart:353:34)
#4 EasyLoading._show (package:flutter_easyloading/src/easy_loading.dart:323:5)
#5 EasyLoading.show (package:flutter_easyloading/src/easy_loading.dart:165:20)
#6 OrderAction.getOrderDetail (package:novo/action/order_action.dart:156:17)
#7 _OrderDetailState.initState (package:novo/page/order/order_detail.dart:66:19)
#8 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4640:58)
#9 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4476:5)
#10 Element.inflat<…>

this place:
void _remove() {
_getInstance().overlayEntry?.remove();
_getInstance()._overlayEntry = null;
_getInstance()._key = null;
_getInstance()._progress = null;
_getInstance()._progressKey = null;
}

@nslogx
Copy link
Owner

nslogx commented Mar 17, 2020

@genius1212
Hi! show me your code and please run flutter doctor then put info here
thanks.

@genius1212
Copy link
Author

1584409983501
1584410204175
this is my code, thank you!

@genius1212
Copy link
Author

i modified here,
..userInteractions = false;

@nslogx
Copy link
Owner

nslogx commented Mar 17, 2020

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    /// child should be [MaterialApp] or [CupertinoApp].
    /// make sure that loading can be displayed in front of all other widgets
    return FlutterEasyLoading(
      child: MaterialApp(
        title: 'Flutter EasyLoading',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: MyHomePage(title: 'Flutter EasyLoading'),
      ),
    );
  }
}

Do you have use FlutterEasyLoading wrap your MaterialApp?

@genius1212
Copy link
Author

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    /// child should be [MaterialApp] or [CupertinoApp].
    /// make sure that loading can be displayed in front of all other widgets
    return FlutterEasyLoading(
      child: MaterialApp(
        title: 'Flutter EasyLoading',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: MyHomePage(title: 'Flutter EasyLoading'),
      ),
    );
  }
}

Do you have use FlutterEasyLoading wrap your MaterialApp?

no use

@nslogx
Copy link
Owner

nslogx commented Mar 17, 2020

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    /// child should be [MaterialApp] or [CupertinoApp].
    /// make sure that loading can be displayed in front of all other widgets
    return FlutterEasyLoading(
      child: MaterialApp(
        title: 'Flutter EasyLoading',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: MyHomePage(title: 'Flutter EasyLoading'),
      ),
    );
  }
}

Do you have use FlutterEasyLoading wrap your MaterialApp?

no use

try it

here is example https://github.com/huangjianke/flutter_easyloading/blob/master/example/lib/main.dart

@genius1212
Copy link
Author

It works, thank you!

@nslogx nslogx closed this as completed Mar 17, 2020
@genius1212
Copy link
Author

genius1212 commented Mar 17, 2020

The problem still exists,
It will appear in the timer
//
_timer = Timer.periodic(Duration(seconds: 1), (Timer timer){
EasyLoading.showToast('Toast');
_timer?.cancel();
});

@genius1212
Copy link
Author

genius1212 commented Mar 17, 2020

@huangjianke
When the toast is in the Timer, it makes an error

[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: 'package:flutter/src/widgets/overlay.dart': Failed assertion: line 132 pos 12: '_overlay != null': is not true.
#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:42:39)
#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:38:5)
#2 OverlayEntry.remove (package:flutter/src/widgets/overlay.dart:132:12)
#3 EasyLoading._remove (package:flutter_easyloading/src/easy_loading.dart:353:34)
#4 EasyLoading.dismiss (package:flutter_easyloading/src/easy_loading.dart:284:20)
#5 EasyLoading._show. (package:flutter_easyloading/src/easy_loading.dart:342:9)
#6 _rootRunUnary (dart:async/zone.dart:1134:38)
#7 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#8 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
#9 _CustomZone.bindUnaryCallbackGuarded. (dart:async/zone.dart:970:26)
#10 _rootRunUnary (dart:async/zone.dart:1138:13)
#11 _Cust<…>

@nslogx
Copy link
Owner

nslogx commented Mar 17, 2020

The problem still exists,
It will appear in the timer
//
_timer = Timer.periodic(Duration(seconds: 1), (Timer timer){
EasyLoading.showToast('Toast');
_timer?.cancel();
});

i will check it soon

@nslogx
Copy link
Owner

nslogx commented Mar 19, 2020

@genius1212 hi, the bug is fixed, thanks for your feedback

dependencies:
  flutter_easyloading: ^1.1.3

@genius1212
Copy link
Author

@genius1212 hi, the bug is fixed, thanks for your feedback

dependencies:
  flutter_easyloading: ^1.1.3

That’s great!

@robertcsouza
Copy link

you need put in main builder: EasyLoading.init();

MaterialApp( title: 'Flutter Demo', initialRoute: '/', routes: routes(), builder: EasyLoading.init(), theme: ThemeData( primarySwatch: Colors.blue, ), home: MyHomePage(title: 'Flutter Demo Home Page'), );

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

3 participants