From efda077f4bfbdc1e7173866c7442b340da6db6c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Thu, 14 Jul 2022 11:45:47 +0100 Subject: [PATCH] feat(bloc_helper): add wrap feature --- .../lib/src/bloc_base/bloc_base_consumer_screen.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/wyatt_bloc_helper/lib/src/bloc_base/bloc_base_consumer_screen.dart b/packages/wyatt_bloc_helper/lib/src/bloc_base/bloc_base_consumer_screen.dart index 0d5e3e96..3fc8e6e2 100644 --- a/packages/wyatt_bloc_helper/lib/src/bloc_base/bloc_base_consumer_screen.dart +++ b/packages/wyatt_bloc_helper/lib/src/bloc_base/bloc_base_consumer_screen.dart @@ -36,6 +36,11 @@ abstract class BlocBaseConsumerScreen, 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, S extends Object> listenWhen: shouldListenWhen, listener: onListen, buildWhen: shouldBuildWhen, - builder: onBuild, + builder: (context, state) => onWrap(context, onBuild(context, state)), ); }