抛出一个异常:MissingPluginException,当试图选择文件上传到Firestore



我正在编写一个代码来上传pdf文件到Firebase Storage,并使用包:FilePicker,但在尝试选择文件时抛出错误。我已经尝试了flutter clean和重建项目。

误差

I/flutter (30101): [MethodChannelFilePicker] Unsupported operation. 
Method not found. The exception thrown was: 
MissingPluginException(No implementation found for method any on channel miguelruivo.flutter.plugins.filepicker)

E/flutter (30101): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled 
Exception: MissingPluginException(No implementation found for method any on channel 
miguelruivo.flutter.plugins.filepicker)

我的代码选择文件

final result=await FilePicker.platform.pickFiles();
if(result==null){
return;
}else{
setState(() {
PlatformFile pdfFile=result.files.first;
});
}

通常当您面临MissingPluginException异常时,原因是没有完全构建项目。这意味着你已经在你的pubspec.yaml file中添加了一些依赖,你没有重建你的项目。试着停止并运行它。你也可以尝试做flutter clean && flutter pub get && flutter run如果停止/启动没有帮助。

有时如果你在yaml文件中添加插件,当它正在运行时,它会发生。

尝试停止应用程序。

然后→Flutter cleanthen ->flutter pub get然后运行你的项目

最新更新