为什么相机不会颤动地打开?
Why doesn't a camera open with flutter?
我正在尝试使用 flutter 打开相机,这就是我得到的结果:
E/flutter (26189):[错误:flutter/lib/ui/ui_dart_state.cc(177)] 未处理的异常:MissingPluginException(未在通道 plugins.flutter.[=38 上找到方法 availableCameras 的实现=])
E/flutter (26189): #0 MethodChannel._invokeMethod (包:flutter/src/services/platform_channel.dart:157:7)
E/flutter (26189): <异步挂起>
E/flutter (26189): #1 availableCameras (package:camera/camera.dart:56:9)
E/flutter (26189): <异步挂起>
E/flutter (26189): #2 主要 (包:flutter_realtime_detection/main.dart:11:15)
E/flutter (26189): <异步挂起>
这是flutter不接受的线:
Future<Null> main() async {
WidgetsFlutterBinding.ensureInitialized();
try {
cameras = await availableCameras();
} on CameraException catch (e) {
print('Error: $e.code\nError Message: $e.message');
}
runApp(new MyApp());
}
我已经尝试过 flutter clean、hot reloads 但没有任何帮助(
这里是flutter doctor -v:
[✓] Flutter (Channel master, 1.24.0-8.0.pre.342, on macOS 11.1 20C69 darwin-x64, locale en-GB)
• Flutter version 1.24.0-8.0.pre.342 at /Users/fimarubin/Developer/flutter \
• Framework revision 226532b157 (4 weeks ago), 2020-11-21 12:08:04 +0100\
• Engine revision 23a8e027db\
• Dart version 2.12.0 (build 2.12.0-62.0.dev)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)\
• Android SDK at /Users/fimarubin/Library/Android/sdk\
• Platform android-30, build-tools 30.0.2\
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java\
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)\
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.3)\
• Xcode at /Applications/Xcode.app/Contents/Developer\
• Xcode 12.3, Build version 12C33\
• CocoaPods version 1.10.0
[✓] Android Studio (version 4.1)\
• Android Studio at /Applications/Android Studio.app/Contents\
• Flutter plugin can be installed from:\
https://plugins.jetbrains.com/plugin/9212-flutter\
• Dart plugin can be installed from:\
https://plugins.jetbrains.com/plugin/6351-dart\
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] Connected device (1 available)\
• SM G9750 (mobile) • R28M31Y893Y • android-arm64 • Android 10 (API 29)
• No issues found!
请确保设置了以下依赖项:
相机:
path_provider:
路径:
dependencies:
flutter:
sdk: flutter
camera:
path_provider:
path:
确保插件服务已初始化,以便可以调用 `availableCameras()
WidgetsFlutterBinding.ensureInitialized();
final cameras = await availableCameras();
我正在尝试使用 flutter 打开相机,这就是我得到的结果:
E/flutter (26189):[错误:flutter/lib/ui/ui_dart_state.cc(177)] 未处理的异常:MissingPluginException(未在通道 plugins.flutter.[=38 上找到方法 availableCameras 的实现=])
E/flutter (26189): #0 MethodChannel._invokeMethod (包:flutter/src/services/platform_channel.dart:157:7)
E/flutter (26189): <异步挂起>
E/flutter (26189): #1 availableCameras (package:camera/camera.dart:56:9)
E/flutter (26189): <异步挂起>
E/flutter (26189): #2 主要 (包:flutter_realtime_detection/main.dart:11:15)
E/flutter (26189): <异步挂起>
这是flutter不接受的线:
Future<Null> main() async {
WidgetsFlutterBinding.ensureInitialized();
try {
cameras = await availableCameras();
} on CameraException catch (e) {
print('Error: $e.code\nError Message: $e.message');
}
runApp(new MyApp());
}
我已经尝试过 flutter clean、hot reloads 但没有任何帮助(
这里是flutter doctor -v:
[✓] Flutter (Channel master, 1.24.0-8.0.pre.342, on macOS 11.1 20C69 darwin-x64, locale en-GB)
• Flutter version 1.24.0-8.0.pre.342 at /Users/fimarubin/Developer/flutter \
• Framework revision 226532b157 (4 weeks ago), 2020-11-21 12:08:04 +0100\
• Engine revision 23a8e027db\
• Dart version 2.12.0 (build 2.12.0-62.0.dev)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)\
• Android SDK at /Users/fimarubin/Library/Android/sdk\
• Platform android-30, build-tools 30.0.2\
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java\
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)\
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.3)\
• Xcode at /Applications/Xcode.app/Contents/Developer\
• Xcode 12.3, Build version 12C33\
• CocoaPods version 1.10.0
[✓] Android Studio (version 4.1)\
• Android Studio at /Applications/Android Studio.app/Contents\
• Flutter plugin can be installed from:\
https://plugins.jetbrains.com/plugin/9212-flutter\
• Dart plugin can be installed from:\
https://plugins.jetbrains.com/plugin/6351-dart\
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] Connected device (1 available)\
• SM G9750 (mobile) • R28M31Y893Y • android-arm64 • Android 10 (API 29)
• No issues found!
请确保设置了以下依赖项:
相机:
path_provider:
路径:
dependencies:
flutter:
sdk: flutter
camera:
path_provider:
path:
确保插件服务已初始化,以便可以调用 `availableCameras()
WidgetsFlutterBinding.ensureInitialized();
final cameras = await availableCameras();