sliver state handler padding support

This commit is contained in:
MohammadTaha Basiri 2022-01-05 18:57:50 +03:30
parent 325f82e52b
commit 32ee689fe5
1 changed files with 11 additions and 3 deletions

View File

@ -11,15 +11,17 @@ class SliverStateHandler<T extends CoreProvier> extends SliverList {
final bool enableEmptyState; final bool enableEmptyState;
final Widget? emptyState; final Widget? emptyState;
final Widget? placeholder; final Widget? placeholder;
final EdgeInsets? itemPadding;
SliverStateHandler({ SliverStateHandler({
Key? key, Key? key,
required this.state,
required this.builder, required this.builder,
required this.childCount, required this.childCount,
this.itemPadding,
this.placeholder, this.placeholder,
this.emptyState, this.emptyState,
this.enableEmptyState = false, this.enableEmptyState = false,
this.onRefresh, this.onRefresh,
required this.state,
}) : super( }) : super(
key: key, key: key,
delegate: SliverChildBuilderDelegate( delegate: SliverChildBuilderDelegate(
@ -31,9 +33,15 @@ class SliverStateHandler<T extends CoreProvier> extends SliverList {
return emptyState; return emptyState;
} }
if (state.appState == AppState.busy) { if (state.appState == AppState.busy) {
return placeholder; return Padding(
padding: itemPadding ?? const EdgeInsets.all(0),
child: placeholder,
);
} }
return builder(context, state, index); return Padding(
padding: itemPadding ?? const EdgeInsets.all(0),
child: builder(context, state, index),
);
}, },
childCount: state.appState == AppState.idle childCount: state.appState == AppState.idle
? childCount ? childCount