[英]Unhandled Exception: MissingPluginException(No implementation found for method X on channel plugins.flutter.io/Y)
[英]Flutter Unhandled Exception: MissingPluginException(No implementation found for method pickImage on channel plugins.flutter.io/image_picker) Error
我正在嘗試在 Windows 10 上使用image_picker 。但是當文件選擇屏幕被觸發時,我收到如下錯誤:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method pickImage on channel plugins.flutter.io/image_picker)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:292:7)
<asynchronous suspension>
#1 ImagePicker.pickImage (package:image_picker/image_picker.dart:64:25)
<asynchronous suspension>
#2 _BolatAktarAppState.build.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:bolataktar_resimyukleme/screens/resimyukleme_main.dart:66:52)
<asynchronous suspension>
這個問題可能是由什么引起的?
代碼:
FloatingActionButton.large(
child: Icon(Icons.folder, color: Colors.white, size: 45,),
backgroundColor: Color.fromARGB(255, 36, 36, 36),
onPressed: () async {
final File image = await ImagePicker.pickImage(source: ImageSource.gallery);
if (image == null) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("the image is not selected."),
backgroundColor: Color.fromARGB(255, 36, 36, 36),
),
);
return null;
}
else {
print("else");
uploadImage("bolat", image);
}
},
),
// ....
void uploadImage(String title, File file) async {
var request = http.MultipartRequest("POST", Uri.parse("https://api.imgur.com/3/image"));
request.fields["title"] = title;
request.headers["Authorization"] = "";
var picture = http.MultipartFile.fromBytes('image', (await rootBundle.load('assets/testimage.png')).buffer.asUint8List(),
filename: 'resimyukle.png');
request.files.add(picture);
var response = await request.send();
var responseData = await response.stream.toBytes();
var result = String.fromCharCodes(responseData);
print(result);
}
感謝幫助。
image_picker
不支持 Windows 僅 Android、iOS 和 web。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.