init method

Future<void> init()

Creates storage instances (if not supplied externally) and loads all entries. Safe to call multiple times — subsequent calls are no-ops.

Implementation

Future<void> init() async {
  if (_initialized) return;
  _isLoading = true;
  notifyListeners();
  try {
    _standard = _externalStandard ?? await JustStorage.standard();
    _secure = _externalSecure ?? await JustStorage.encrypted();
    await _load();
    _initialized = true;
    _error = null;
  } catch (e) {
    _error = 'Initialization failed: $e';
  } finally {
    _isLoading = false;
    notifyListeners();
  }
}