颤音:`camera_android`丢弃了一个错误:绑定尚未初始化
回归。升级插件后,我的应用不再启动。
这是我的颤音规格:
上是最新的。
扑朔迷离已经在通道稳定 com/flutter/flutter.git“ rel =“ nofollow noreferrer”> https://github.com/flutter/flutter.git.git
框架•修订CD41FDD(10天前)•20222222222222年-06-08 09:52:13 -0700
引擎•修订版F15F824B57 工具•飞镖2.17.3•DevTools 2.12.2
以前每个人都可以正常工作,但我遇到了这个错误:
I/flutter ( 6677): `camera_android` threw an error: Binding has not yet been initialized.
I/flutter ( 6677): The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
I/flutter ( 6677): Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After calling that method, the "instance" getter will return the binding.
I/flutter ( 6677): In a test, one can call "TestWidgetsFlutterBinding.ensureInitialized()" as the first line in the test's "main()" method to initialize the binding.
I/flutter ( 6677): If ServicesBinding is a custom binding mixin, there must also be a custom binding class, like WidgetsFlutterBinding, but that mixes in the selected binding, and that is the class that must be constructed before using the "instance" getter.. The app may not function as expected until you remove this plugin from pubspec.yaml
E/flutter ( 6677): [ERROR:flutter/shell/common/shell.cc(93)] Dart Unhandled Exception: Binding has not yet been initialized.
E/flutter ( 6677): The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
E/flutter ( 6677): Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After calling that method, the "instance" getter will return the binding.
E/flutter ( 6677): In a test, one can call "TestWidgetsFlutterBinding.ensureInitialized()" as the first line in the test's "main()" method to initialize the binding.
E/flutter ( 6677): If ServicesBinding is a custom binding mixin, there must also be a custom binding class, like WidgetsFlutterBinding, but that mixes in the selected binding, and that is the class that must be constructed before using the "instance" getter., stack trace: #0 BindingBase.checkInstance.<anonymous closure> (package:flutter/src/foundation/binding.dart:281:9)
E/flutter ( 6677): #1 BindingBase.checkInstance (package:flutter/src/foundation/binding.dart:363:6)
E/flutter ( 6677): #2 ServicesBinding.instance (package:flutter/src/services/binding.dart:48:54)
E/flutter ( 6677): #3 MethodChannel.setMethodCallHandler (package:flutter/src/services/platform_channel.dart:387:51)
E/flutter ( 6677): #4 new AndroidCamera (package:camera_android/src/android_camera.dart:26:13)
E/flutter ( 6677): #5 AndroidCamera.registerWith (package:camera_android/src/android_camera.dart:32:31)
E/flutter ( 6677): #6 _PluginRegistrant.register (file:///Users/manish/Documents/REBORN/flutter/user-app/.dart_tool/flutter_build/dart_plugin_registrant.dart:47:23)
E/flutter ( 6677):
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
为我工作
Worked for me
是的,他们释放了 0.9.8+1 作为破损的构建。
https://github.com/github.com/flutter/flutter/flutter/issues/106236#issuecomment-106236#issuecomment- 1161100481
建议
在修复构建之前,我建议:
httpps://github.com/颤动/扑朔迷离/发行/106236#issuecomment-1161149799
https://pub.dev/packages/packages/camera/versions
flutter
Flutter Pub Get
不建议
其他解决方案是覆盖依赖项
我不建议这种方法,因为(a)构建已损坏,这是一个可能无法解决所有问题的黑客,((( b)这些是其他代码行,它们会减慢您的构建并将其添加到存储库历史记录中,并且(c)您需要记住要删除这些代码行。
Flutter团队也不建议这种方法。他们将覆盖代码称为“反模式” ...
https://github.com/github.com/github.com/flutter/flutter/flutter/flutter/106236#issuecomment/106236#issuecomment/106236#issuecomment- 1162916231
https://github.com/github.com/github.com/flutter/flutter/flutter/flutter/106236#issuecomment/106236#issuecomment/106236#issuecomment- 1162941742
Yeah, they released 0.9.8+1 as a broken build.
https://github.com/flutter/flutter/issues/106236#issuecomment-1161100481
Recommended
Until they fix the build, I recommend:
https://github.com/flutter/flutter/issues/106236#issuecomment-1161149799
https://pub.dev/packages/camera/versions
flutter pub get
Not recommend at all
Another solution would be to override dependencies
https://github.com/flutter/flutter/issues/106236#issuecomment-1159447210
I don't recommend this approach, because (a) the build is broken, and this is a hack that might not fix all issues, (b) these are additional lines of code that slow down your build and get added to your repository history, and (c) you'll need to remember to remove these lines of code.
The Flutter team also does not recommend this approach. They refer to the override code as an "anti-pattern[s]"...
https://github.com/flutter/flutter/issues/106236#issuecomment-1162916231
https://github.com/flutter/flutter/issues/106236#issuecomment-1162941742
这不是答案,但是这种解决方法对我有帮助(在Pubspec.yaml中):
Not an answer but this workaround helped me (in pubspec.yaml):
然后将其添加到您的pubspec.yaml文件中
,然后在您的终端运行中:
请注意,您会在终端中看到一些与此替代有关的警告,但现在可以忽略它们。
您可以参考此问题,您可以在
add this to your pubspec.yaml file
then in your terminal run :
Note you will see some warnings in your terminal related to this override but thats okay for now you can ignore them.
and more reference to this you can check this issue at Github