add room access settings

This commit is contained in:
Henry Hiles 2026-10-22 14:22:54 -04:00
commit b390dbbbe1
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View 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;
}
},
);
}
}