getInstance static method

Future<SpUtil?> getInstance()

Implementation

static Future<SpUtil?> getInstance() async {
  if (_singleton == null) {
    await _lock.synchronized(() async {
      if (_singleton == null) {
        // keep local instance till it is fully initialized.
        // 保持本地实例直到完全初始化。
        var singleton = SpUtil._();
        await singleton._init();
        _singleton = singleton;
      }
    });
  }
  return _singleton;
}