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

Merged
hugo merged 1 commits from refactor/bloc_helper/onwrap_naming into master 2022-11-24 23:19:06 +00:00
4 changed files with 13 additions and 13 deletions

View File

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