Files
cutdex/lib/settings/settings_operation.dart
T
lingjhf 27e77fff39 feat: initial Cutdex application
Add the Flutter video editing application with project management, media
import, timeline editing, preview, AI assistance, diagnostics and settings.

Include shared UI and native host packages, platform runners, application
tests and release tooling.

Provide usage and contribution guides, the MIT license and third-party
notices. Exclude local credentials, build outputs and validation data.
2026-10-05 23:36:23 +08:00

30 lines
866 B
Dart

import 'package:riverpod_annotation/riverpod_annotation.dart';
import '../diagnostics/app_diagnostics.dart';
part 'settings_operation.g.dart';
/// Tracks an operation independently of the configuration currently in effect.
@riverpod
class SettingsOperation extends _$SettingsOperation {
@override
AsyncValue<void> build(String operation) => const AsyncData(null);
Future<bool> run(Future<void> Function() action) async {
if (state.isLoading) return false;
final lease = ref.keepAlive();
state = const AsyncLoading();
try {
await action();
if (ref.mounted) state = const AsyncData(null);
return true;
} catch (error, stack) {
AppDiagnostics.failure('settings', operation, error, stack);
if (ref.mounted) state = AsyncError(error, stack);
return false;
} finally {
lease.close();
}
}
}