add room access settings
This commit is contained in:
parent
8e51852ae3
commit
b390dbbbe1
2 changed files with 974 additions and 128 deletions
|
|
@ -8,10 +8,12 @@ extension BetterWhen<T> on AsyncValue<T> {
|
|||
required Widget Function(T value) data,
|
||||
Widget Function() loading = Loading.new,
|
||||
bool skipLoadingOnRefresh = false,
|
||||
bool skipLoadingOnReload = false,
|
||||
}) => when(
|
||||
data: data,
|
||||
error: (error, stackTrace) => ErrorDialog(error, stackTrace),
|
||||
loading: loading,
|
||||
skipLoadingOnRefresh: skipLoadingOnRefresh,
|
||||
skipLoadingOnReload: skipLoadingOnReload,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
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