wip: bloc for files

This commit is contained in:
2024-08-23 20:49:19 +02:00
parent 54b777237f
commit 5bdfb9f766
7 changed files with 73 additions and 56 deletions

View File

@ -17,13 +17,16 @@ class LoadableStateConsumer<TController extends Bloc<LoadableHydratedBlocEvent<T
final Widget Function(TState state, bool loading) child;
final void Function(TState state)? onLoad;
final bool wrapWithScrollView;
const LoadableStateConsumer({required this.child, this.onLoad, this.wrapWithScrollView = false, super.key});
final TController? controllerByValue;
const LoadableStateConsumer({required this.child, this.onLoad, this.wrapWithScrollView = false, this.controllerByValue = null, super.key});
static Duration animationDuration = const Duration(milliseconds: 200);
@override
Widget build(BuildContext context) {
var loadableState = context.watch<TController>().state;
var loadableState = controllerByValue != null
? controllerByValue!.state
: context.watch<TController>().state;
if(!loadableState.isLoading && onLoad != null) {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) => onLoad!(loadableState.data));