getInstance static method

Future<SpUtil> getInstance()

初始化SharedPreferences缓存对象

Implementation

static Future<SpUtil> getInstance() async {
  await _lock.synchronized(() async {
    if (_prefs == null) {
      _singleton = SpUtil._();
      _prefs = await SharedPreferences.getInstance();
    }
  });
  return _singleton as SpUtil;
}