- 报错:
MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)
- 解决:
shared_preferences 0.2.4
及更高版本,请使用setMockInitialValues
void main() {
SharedPreferences.setMockInitialValues({});
runApp( MyApp());
}
更早的版本,你可以手动进行操作:
const MethodChannel('plugins.Flutter.io/shared_preferences')
.setMockMethodCallHandler((MethodCall methodCall) async {
if (methodCall.method == 'getAll') {
return <String, dynamic>{}; // set initial values here if desired
}
return null;
});
评论(0)