我在path_provider调用方法<String>( "getApplicationDocumentsDirectory" ) 时出错


[ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter (23720): NoSuchMethodError: Class 'MethodChannel' has no instance method 'invokeMethod' with matching arguments.
E/flutter (23720): Receiver: Instance of 'MethodChannel'
E/flutter (23720): Tried calling: invokeMethod<String>("getApplicationDocumentsDirectory")
E/flutter (23720): Found: invokeMethod(String, [dynamic]) => Future<dynamic>
E/flutter (23720): #0      Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
E/flutter (23720): #1      getApplicationDocumentsDirectory (package:path_provider/path_provider.dart:65:22)
E/flutter (23720): <asynchronous suspension>
E/flutter (23720): #2      DatabaseHelper.initializeDb (package:snote/snote/utils/database_helper.dart:45:36)
E/flutter (23720): <asynchronous suspension>

此问题之所以发生,是因为您不使用最新版本的DART。我描述了两种解决此错误的解决方案。

解决方案1:使用PATH提供商的先前版本即: PATH_PROVIDER:1.0.0

解决方案2:如果要使用最新版本的路径提供商,请更新您的颤音并飞镖到最新版本。

最新更新