You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Hive.initFlutter()报错:path_provider方法getApplicationDocumentsDirectory无实现

Hive.initFlutter()引发黑屏,path_provider报MissingPluginException异常

我在使用Hive进行本地数据存储时,按照要求在main()函数中调用了Hive.initFlutter(),但运行应用后屏幕持续黑屏。排查后发现,问题出在Hive.initFlutter()内部调用path_provider包的await _platform.getApplicationDocumentsPath()时无法正常执行,具体报错信息如下:

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:313:7)
<asynchronous suspension>
#1      getApplicationDocumentsDirectory (package:path_provider.dart:120:24)
<asynchronous suspension>
#2      HiveX.initFlutter (package:hive_flutter/src/hive_extensions.dart:12:18)
<asynchronous suspension>
#3      main (package:myapp/main.dart:133:3)
<asynchronous suspension>

我已经尝试过执行flutter clean并重启应用(未使用热重载),但问题依然存在,希望有相关解决经验的人分享可行的方案。

相关依赖版本:

dependencies:
  path_provider: ^2.0.14
  hive: ^2.2.3
  hive_flutter: ^1.1.0

Flutter/Dart版本信息:
Flutter/Dart版本信息

内容的提问来源于stack exchange,提问作者Seongchan Kim

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 09:22:44