add room access settings
This commit is contained in:
parent
8e51852ae3
commit
b390dbbbe1
1 changed files with 974 additions and 128 deletions
25
lib/helpers/hooks/saving.dart
Normal file
25
lib/helpers/hooks/saving.dart
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import "dart:async";
|
||||
|
||||
import "package:flutter_hooks/flutter_hooks.dart";
|
||||
|
||||
final class Saving({
|
||||
required final bool active,
|
||||
required final Future<void> Function(FutureOr<void> Function() action) run,
|
||||
}) {
|
||||
factory use() {
|
||||
final context = useContext();
|
||||
final active = useState(false);
|
||||
|
||||
return .new(
|
||||
active: active.value,
|
||||
run: (action) async {
|
||||
active.value = true;
|
||||
try {
|
||||
await action();
|
||||
} finally {
|
||||
if (context.mounted) active.value = false;
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue