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

@ -1,17 +1,17 @@
<!--
* Copyright (C) 2022 WYATT GROUP
* Please see the AUTHORS file for details.
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
@ -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
@override
Widget onWrap(BuildContext context, Widget child) {
Widget parent(BuildContext context, Widget child) {
return Scaffold(
appBar: AppBar(
title: const Text('Title'),
@ -171,4 +171,4 @@ Widget onBuild(BuildContext context, CounterState state) {
> Note: check **BlocProvider** and **BlocConsumer** documentation for more information.
You'll find a more examples in the `example/lib/counter/` directory.
You'll find a more examples in the `example/lib/counter/` directory.

View File

@ -62,7 +62,7 @@ abstract class BlocProviderScreen<Bloc extends blocbase.Bloc<Event, State>,
/// [shouldListenWhen] and [shouldBuildWhen] are optional and if they
/// 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.
/// {@endtemplate}
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
/// 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.
/// {@endtemplate}
abstract class BlocBaseConsumerScreen<Bloc extends BlocBase<State>,
@ -51,10 +51,10 @@ abstract class BlocBaseConsumerScreen<Bloc extends BlocBase<State>,
/// [onListen] with the current `state`.
bool shouldListenWhen(State previous, State current) => true;
/// The [onWrap] function which will be invoked on build.
/// The [onWrap] takes a `BuildContext` that **doesn't have** access
/// The [parent] function which will be invoked on build.
/// The [parent] takes a `BuildContext` that **doesn't have** access
/// 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] takes the `BuildContext` and current `state` and
@ -66,7 +66,7 @@ abstract class BlocBaseConsumerScreen<Bloc extends BlocBase<State>,
void onListen(BuildContext context, State state) {}
@override
Widget build(BuildContext context) => onWrap(
Widget build(BuildContext context) => parent(
context,
BlocConsumer<Bloc, State>(
listenWhen: shouldListenWhen,

View File

@ -58,7 +58,7 @@ abstract class CubitProviderScreen<Cubit extends blocbase.Cubit<State>,
/// [shouldListenWhen] and [shouldBuildWhen] are optional and if they
/// 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.
/// {@endtemplate}
abstract class CubitConsumerScreen<Cubit extends blocbase.Cubit<State>,