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

大佬帮我看看 报了这个错 #39

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

大佬帮我看看 报了这个错 #39

FullChargeComplete opened this issue Mar 13, 2020 · 17 comments
Labels

Comments

@FullChargeComplete
Copy link

flutter: ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following assertion was thrown during a scheduler callback:
flutter: 'package:flutter/src/widgets/overlay.dart': Failed assertion: line 132 pos 12: '_overlay != null':
flutter: is not true.
flutter:
flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially
flutter: more information in this error message to help you determine and fix the underlying cause.
flutter: In either case, please report this assertion by filing a bug on GitHub:
flutter: https://github.com/flutter/flutter/issues/new?template=BUG.md
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #2 OverlayEntry.remove (package:flutter/src/widgets/overlay.dart:132:12)
flutter: #3 BotToastManager.removeAll.. (package:bot_toast/src/bot_toast_manager.dart:132:15)
flutter: #4 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
flutter: #5 BotToastManager.removeAll. (package:bot_toast/src/bot_toast_manager.dart:130:23)
flutter: #6 safeRun. (package:bot_toast/src/toast.dart:15:13)
flutter: #7 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1102:15)
flutter: #8 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1049:9)
flutter: #9 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:957:5)
flutter: #13 _invoke (dart:ui/hooks.dart:259:10)
flutter: #14 _drawFrame (dart:ui/hooks.dart:217:3)
flutter: (elided 5 frames from class _AssertionError and package dart:async)

@MMMzq
Copy link
Owner

MMMzq commented Mar 13, 2020

@FullChargeComplete
请问你是在调用closeAllLoading报的错吗?

@FullChargeComplete
Copy link
Author

是的 �我调用了 BotToast.closeAllLoading();

@FullChargeComplete
Copy link
Author

可能是toast 已经被close 掉了才报这个错

@MMMzq
Copy link
Owner

MMMzq commented Mar 13, 2020

@FullChargeComplete
这种情况是稳定复习的还是概率性的?

@MMMzq
Copy link
Owner

MMMzq commented Mar 13, 2020

closeAllLoading我在项目及基本没有用,所以该方法的测试可能没有其他方法那么完全.

@FullChargeComplete
Copy link
Author

应该是我的问题 我每次请求会自动 toast 一下 完成都会closeAll ,有没有检查 是否还有toast 存在的方法?

@MMMzq
Copy link
Owner

MMMzq commented Mar 13, 2020

  1. closeAllLoading正常来说,多次调用是OK的,出现现在这种情况说明 closeAllLoading还是有点问题的
  2. 没有检查的功能

不知道能不能提供一个能复现的demo?

@FullChargeComplete
Copy link
Author

FullChargeComplete commented Mar 13, 2020

import 'package:bot_toast/bot_toast.dart';

bool loading = false;
Set dict = Set();

void beforeRequest(uri, Map<dynamic, dynamic> options) {
  dict.add(uri);
  if (loading == false) {
    showAppLoading(options);
    loading = true;
  }
}

void afterResponse(uri, Map<dynamic, dynamic> options) {
  dict.remove(uri);
  if (dict.length == 0 && loading == true) {
     BotToast.closeAllLoading();
    loading = false;
  }
}

/*
 * loading: 可配置参数
 * requestOrComplete: 是否发送请求或已完成 true表示发送请求需要开启loading,false表示完成请求可关闭loading
 */
void showAppLoading(Map<dynamic, dynamic> options) {
  options = {
    'text': options['text'] ?? 'loading...'
  };
   BotToast.showLoading();
  
}

@FullChargeComplete
Copy link
Author

这个是我的代码

@MMMzq
Copy link
Owner

MMMzq commented Mar 13, 2020

@FullChargeComplete
看起来很正常,你现在是每次都能重现吗?

@FullChargeComplete
Copy link
Author

对的 经常出现
还有 在BotToast.showText 回调 pop 会报错
BotToast.showText(text: '提现申请提交成功,等待后台审核',onClose: (){
Navigator.pop(context);
});

报这个
flutter: Another exception was thrown: setState() or markNeedsBuild() called when widget tree was locked.
我没有在回调里面setstate

@MMMzq
Copy link
Owner

MMMzq commented Mar 16, 2020

@FullChargeComplete
Navigator.pop(context); 会间接调用相关方法.注意的是onClose的触发时机是Toast的dispose函数,所以说你可能需要使用 SchedulerBinding.instance.addPostFrameCallback包裹.像下面这样

  SchedulerBinding.instance.addPostFrameCallback((_) {
    Navigator.pop(context);
  });

@MMMzq
Copy link
Owner

MMMzq commented Mar 16, 2020

你能尝试把:
bot_toast_manager.dart
这一行改成下面那样,看看有没有问题?

_map.clear();

@FullChargeComplete
Copy link
Author

嗯嗯 谢谢大佬 我试试

@MMMzq MMMzq added the bug Something isn't working label Mar 17, 2020
@MMMzq
Copy link
Owner

MMMzq commented Mar 21, 2020

@FullChargeComplete
你好,我这边修改了一下,你这边方便使用下dev分支来测试一下有没有问题吗?
使用方式:

dependency_overrides:
  bot_toast:
    git:
      url: https://github.com/MMMzq/bot_toast.git
      ref: dev

@MMMzq
Copy link
Owner

MMMzq commented Mar 21, 2020

这个错误本质上应该是和 #43 是一样的

@no-response
Copy link

no-response bot commented Mar 29, 2020

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away!

@no-response no-response bot closed this as completed Mar 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants