refactor(bloc_helper)!: update onWrap label (close #46)

This commit is contained in:
AN12345 2022-11-24 18:16:20 -05:00
parent 45312473d1
commit c3315d968c
4 changed files with 13 additions and 13 deletions

View File

@ -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'),

View File

@ -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>,

View File

@ -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,

View File

@ -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>,