refactor(bloc_helper)!: update onWrap label (close #46) #52
| @ -116,11 +116,11 @@ Widget onBuild(BuildContext context, CounterState state) { | |||||||
| } | } | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| If needed, you can wrap what depends on the state with the function `onWrap`. | If needed, you can wrap what depends on the state with the function `parent`. | ||||||
| 
 | 
 | ||||||
| ```dart | ```dart | ||||||
| @override | @override | ||||||
| Widget onWrap(BuildContext context, Widget child) { | Widget parent(BuildContext context, Widget child) { | ||||||
|     return Scaffold( |     return Scaffold( | ||||||
|         appBar: AppBar( |         appBar: AppBar( | ||||||
|             title: const Text('Title'), |             title: const Text('Title'), | ||||||
|  | |||||||
| @ -62,7 +62,7 @@ abstract class BlocProviderScreen<Bloc extends blocbase.Bloc<Event, State>, | |||||||
| /// [shouldListenWhen] and [shouldBuildWhen] are optional and if they | /// [shouldListenWhen] and [shouldBuildWhen] are optional and if they | ||||||
| /// aren't implemented, they will default to `true`. | /// aren't implemented, they will default to `true`. | ||||||
| /// | /// | ||||||
| /// An optional [onWrap] can also be implemented. This build a wrapper arround | /// An optional [parent] can also be implemented. This build a wrapper arround | ||||||
| /// the built BlocConsumer that is **not** rebuild on each state. | /// the built BlocConsumer that is **not** rebuild on each state. | ||||||
| /// {@endtemplate} | /// {@endtemplate} | ||||||
| abstract class BlocConsumerScreen<Bloc extends blocbase.Bloc<Event, State>, | abstract class BlocConsumerScreen<Bloc extends blocbase.Bloc<Event, State>, | ||||||
|  | |||||||
| @ -33,7 +33,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; | |||||||
| /// [shouldListenWhen] and [shouldBuildWhen] are optional and if they | /// [shouldListenWhen] and [shouldBuildWhen] are optional and if they | ||||||
| /// aren't implemented, they will default to `true`. | /// aren't implemented, they will default to `true`. | ||||||
| /// | /// | ||||||
| /// An optional [onWrap] can also be implemented. This build a wrapper arround | /// An optional [parent] can also be implemented. This build a wrapper arround | ||||||
| /// the built [BlocConsumer] that is **not** rebuild on each state. | /// the built [BlocConsumer] that is **not** rebuild on each state. | ||||||
| /// {@endtemplate} | /// {@endtemplate} | ||||||
| abstract class BlocBaseConsumerScreen<Bloc extends BlocBase<State>, | abstract class BlocBaseConsumerScreen<Bloc extends BlocBase<State>, | ||||||
| @ -51,10 +51,10 @@ abstract class BlocBaseConsumerScreen<Bloc extends BlocBase<State>, | |||||||
|   /// [onListen] with the current `state`. |   /// [onListen] with the current `state`. | ||||||
|   bool shouldListenWhen(State previous, State current) => true; |   bool shouldListenWhen(State previous, State current) => true; | ||||||
| 
 | 
 | ||||||
|   /// The [onWrap] function which will be invoked on build. |   /// The [parent] function which will be invoked on build. | ||||||
|   /// The [onWrap] takes a `BuildContext` that **doesn't have** access |   /// The [parent] takes a `BuildContext` that **doesn't have** access | ||||||
|   /// to the [Bloc] or [Cubit]. |   /// to the [Bloc] or [Cubit]. | ||||||
|   Widget onWrap(BuildContext context, Widget child) => child; |   Widget parent(BuildContext context, Widget child) => child; | ||||||
| 
 | 
 | ||||||
|   /// The [onBuild] function which will be invoked on each widget build. |   /// The [onBuild] function which will be invoked on each widget build. | ||||||
|   /// The [onBuild] takes the `BuildContext` and current `state` and |   /// The [onBuild] takes the `BuildContext` and current `state` and | ||||||
| @ -66,7 +66,7 @@ abstract class BlocBaseConsumerScreen<Bloc extends BlocBase<State>, | |||||||
|   void onListen(BuildContext context, State state) {} |   void onListen(BuildContext context, State state) {} | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   Widget build(BuildContext context) => onWrap( |   Widget build(BuildContext context) => parent( | ||||||
|         context, |         context, | ||||||
|         BlocConsumer<Bloc, State>( |         BlocConsumer<Bloc, State>( | ||||||
|           listenWhen: shouldListenWhen, |           listenWhen: shouldListenWhen, | ||||||
|  | |||||||
| @ -58,7 +58,7 @@ abstract class CubitProviderScreen<Cubit extends blocbase.Cubit<State>, | |||||||
| /// [shouldListenWhen] and [shouldBuildWhen] are optional and if they | /// [shouldListenWhen] and [shouldBuildWhen] are optional and if they | ||||||
| /// aren't implemented, they will default to `true`. | /// aren't implemented, they will default to `true`. | ||||||
| /// | /// | ||||||
| /// An optional [onWrap] can also be implemented. This build a wrapper arround | /// An optional [parent] can also be implemented. This build a wrapper arround | ||||||
| /// the built BlocConsumer that is **not** rebuild on each state. | /// the built BlocConsumer that is **not** rebuild on each state. | ||||||
| /// {@endtemplate} | /// {@endtemplate} | ||||||
| abstract class CubitConsumerScreen<Cubit extends blocbase.Cubit<State>, | abstract class CubitConsumerScreen<Cubit extends blocbase.Cubit<State>, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user