openSystemSettings method

Future<void> openSystemSettings()

Implementation

Future<void> openSystemSettings() async {
  final current = state.value;
  if (current == null || _saving || current.isSaving) return;
  final version = ++_requestVersion;
  _saving = true;
  state = AsyncData(current.copyWith(isSaving: true, clearError: true));
  try {
    await ref.read(languageRepositoryProvider).openSystemSettings();
    if (ref.mounted && version == _requestVersion) {
      state = AsyncData(current.copyWith(isSaving: false));
    }
  } catch (_) {
    if (ref.mounted && version == _requestVersion) {
      state = AsyncData(
        current.copyWith(
          isSaving: false,
          error: PreferenceDetailError.action,
        ),
      );
    }
  } finally {
    _saving = false;
  }
}