'!_debugLocked':不正确
功能:
navigateToAudioScreen(file, aPlay) async {
// await Future.delayed(Duration(seconds: 3));
WidgetsBinding.instance!.addPostFrameCallback((_) async {
await Future.delayed(Duration(seconds: 3));
Navigator.pop(context, MaterialPageRoute(builder: (context) {
return AudioPlayerScreen(
a_play: aPlay,
a_file: file,
);
}));
}
);
}
错误:
flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: 'package:flutter/src/widgets/navigato
r.dart': Failed assertion: line 4842 pos 12: '!_debugLocked': is not true.
E/flutter (11069): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:47:61)
E/flutter (11069): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
E/flutter (11069): #2 NavigatorState.pop (package:flutter/src/widgets/navigator.dart:4842:12)
E/flutter (11069): #3 Navigator.pop (package:flutter/src/widgets/navigator.dart:2432:27)
E/flutter (11069): #4 _HomePageState.navigateToAudioScreen.<anonymous closure> (/Screens/Home.dart:95
:17)
尝试:
- 尝试添加调度程序绑定
- 尝试添加小部件绑定
- 尝试添加未来延迟
Function:
navigateToAudioScreen(file, aPlay) async {
// await Future.delayed(Duration(seconds: 3));
WidgetsBinding.instance!.addPostFrameCallback((_) async {
await Future.delayed(Duration(seconds: 3));
Navigator.pop(context, MaterialPageRoute(builder: (context) {
return AudioPlayerScreen(
a_play: aPlay,
a_file: file,
);
}));
}
);
}
Error:
flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: 'package:flutter/src/widgets/navigato
r.dart': Failed assertion: line 4842 pos 12: '!_debugLocked': is not true.
E/flutter (11069): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:47:61)
E/flutter (11069): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
E/flutter (11069): #2 NavigatorState.pop (package:flutter/src/widgets/navigator.dart:4842:12)
E/flutter (11069): #3 Navigator.pop (package:flutter/src/widgets/navigator.dart:2432:27)
E/flutter (11069): #4 _HomePageState.navigateToAudioScreen.<anonymous closure> (/Screens/Home.dart:95
:17)
Attempts:
- Tried adding Scheduler Bind
- Tried adding Widget Bind
- Tried adding Future Delay
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此错误可能是因为
Navigator.pop()
方法不将 MaterialPageRoute 作为参数,因此引发此错误。您可以在以下位置查看更多信息: https://api.flutter.dev/ flutter/widgets/Navigator/pop.html
This error might be because
Navigator.pop()
method does not take MaterialPageRoute as a parameter and hence it is throwing this error.You can check more on this at: https://api.flutter.dev/flutter/widgets/Navigator/pop.html