Sky24n / sp_util

Flutter shared_preferences plugin util.
BSD 3-Clause "New" or "Revised" License
36 stars 21 forks source link

初始化出错 #5

Closed AKA-LinCoder closed 3 years ago

AKA-LinCoder commented 3 years ago

[VERBOSE-2:ui_dart_state.cc(199)] Unhandled Exception: Null check operator used on a null value

0 MethodChannel.binaryMessenger (package:flutter/src/services/platform_channel.dart:142:86)

1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:148:36)

2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:331:12)

3 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:358:49)

4 MethodChannelSharedPreferencesStore.getAll (package:shared_preferences_platform_interface/method_channel_shared_preferences.dart:44:25)

5 SharedPreferences._getSharedPreferencesMap (package:shared_preferences/shared_preferences.dart:180:57)

6 SharedPreferences.getInstance (package:shared_preferences/shared_preferences.dart:56:19)

7 SpUtil._init (package:sp_util/sp_util.dart:41:38)

8 SpUtil.getInstance. (package:sp_util/sp_util.dart:30:27)

9 SpUtil.getInstance.<anonymous <…>

你好,我在使用这个库的时候,进行初始化时报了这个初始化错误的错,使用您pub上面的例子也是这样,

AKA-LinCoder commented 3 years ago

哦,我发现了,得加上你GitHub例子里面的 WidgetsFlutterBinding.ensureInitialized();不好意思