feat(bloc_helper): add wrap feature
This commit is contained in:
parent
e00f4f55b7
commit
efda077f4b
@ -36,6 +36,11 @@ abstract class BlocBaseConsumerScreen<B extends BlocBase<S>, S extends Object>
|
||||
/// must return a widget.
|
||||
Widget onBuild(BuildContext context, S state);
|
||||
|
||||
/// The [onWrap] function which will be invoked on each widget build.
|
||||
/// The [onWrap] takes the `BuildContext`
|
||||
/// Used to wrap which depends on the state.
|
||||
Widget onWrap(BuildContext context, Widget child) => child;
|
||||
|
||||
/// Takes the `BuildContext` along with the `state`
|
||||
/// and is responsible for executing in response to `state` changes.
|
||||
void onListen(BuildContext context, S state) {}
|
||||
@ -45,6 +50,6 @@ abstract class BlocBaseConsumerScreen<B extends BlocBase<S>, S extends Object>
|
||||
listenWhen: shouldListenWhen,
|
||||
listener: onListen,
|
||||
buildWhen: shouldBuildWhen,
|
||||
builder: onBuild,
|
||||
builder: (context, state) => onWrap(context, onBuild(context, state)),
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user