chore: fix and format using melos
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
// 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/>.
|
||||
|
||||
@@ -25,7 +25,6 @@ class CounterBloc extends Bloc<CounterEvent, CounterState> {
|
||||
final CounterRepository counterRepository;
|
||||
|
||||
CounterBloc(this.counterRepository) : super(const CounterInitial()) {
|
||||
|
||||
on<CounterIncrement>((event, emit) {
|
||||
emit(CounterModified(counterRepository.increment(state.count)));
|
||||
});
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// 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/>.
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// 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/>.
|
||||
|
||||
@@ -32,4 +32,3 @@ class CounterInitial extends CounterState {
|
||||
class CounterModified extends CounterState {
|
||||
const CounterModified(super.count);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,14 +24,16 @@ class CounterBlocPage
|
||||
const CounterBlocPage({super.key});
|
||||
|
||||
@override
|
||||
CounterBloc create(BuildContext context) => CounterBloc(repo<CounterRepository>(context));
|
||||
CounterBloc create(BuildContext context) =>
|
||||
CounterBloc(repo<CounterRepository>(context));
|
||||
|
||||
@override
|
||||
Widget onBuild(BuildContext context, CounterState state) {
|
||||
final textTheme = Theme.of(context).textTheme;
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Counter with Bloc')),
|
||||
body: Center(child: Text('${state.count}', style: textTheme.headline2)),
|
||||
body:
|
||||
Center(child: Text('${state.count}', style: textTheme.displayMedium)),
|
||||
floatingActionButton: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
|
||||
@@ -28,7 +28,8 @@ class CounterConsumerPage
|
||||
final textTheme = Theme.of(context).textTheme;
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Counter with Consumer')),
|
||||
body: Center(child: Text('${state.count}', style: textTheme.headline2)),
|
||||
body:
|
||||
Center(child: Text('${state.count}', style: textTheme.displayMedium)),
|
||||
floatingActionButton: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// 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/>.
|
||||
|
||||
@@ -19,19 +19,20 @@ import 'package:bloc_helper_example/counter/repository/counter_repository.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart';
|
||||
|
||||
class CounterCubitPage
|
||||
extends CubitScreen<CounterCubit, CounterState> {
|
||||
class CounterCubitPage extends CubitScreen<CounterCubit, CounterState> {
|
||||
const CounterCubitPage({super.key});
|
||||
|
||||
@override
|
||||
CounterCubit create(BuildContext context) => CounterCubit(repo<CounterRepository>(context));
|
||||
CounterCubit create(BuildContext context) =>
|
||||
CounterCubit(repo<CounterRepository>(context));
|
||||
|
||||
@override
|
||||
Widget onBuild(BuildContext context, CounterState state) {
|
||||
final textTheme = Theme.of(context).textTheme;
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Counter with Cubit')),
|
||||
body: Center(child: Text('${state.count}', style: textTheme.headline2)),
|
||||
body:
|
||||
Center(child: Text('${state.count}', style: textTheme.displayMedium)),
|
||||
floatingActionButton: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
@@ -53,4 +54,4 @@ class CounterCubitPage
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class CounterProviderPage
|
||||
appBar: AppBar(title: const Text('Counter with Provider')),
|
||||
body: Center(child: BlocBuilder<CounterBloc, CounterState>(
|
||||
builder: (context, state) {
|
||||
return Text('${state.count}', style: textTheme.headline2);
|
||||
return Text('${state.count}', style: textTheme.displayMedium);
|
||||
},
|
||||
)),
|
||||
floatingActionButton: Column(
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// 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/>.
|
||||
|
||||
@@ -32,4 +32,3 @@ class CounterInitial extends CounterState {
|
||||
class CounterModified extends CounterState {
|
||||
const CounterModified(super.count);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// 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/>.
|
||||
|
||||
@@ -23,4 +23,4 @@ class CounterObserver extends BlocObserver {
|
||||
super.onChange(bloc, change);
|
||||
debugPrint('${bloc.runtimeType} $change');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,8 @@ class MainPage extends StatelessWidget {
|
||||
onPressed: () => Navigator.of(context)
|
||||
.push(MaterialPageRoute(builder: (context) {
|
||||
return BlocProvider<CounterCubit>(
|
||||
create: (context) => CounterCubit(context.read<CounterRepository>()),
|
||||
create: (context) =>
|
||||
CounterCubit(context.read<CounterRepository>()),
|
||||
child: const CounterConsumerPage(),
|
||||
);
|
||||
})),
|
||||
|
||||
@@ -25,7 +25,7 @@ mixin BlocBaseProviderMixin<Bloc extends BlocBase<Object>> {
|
||||
|
||||
/// Returns another [BlocBase] **not** used by this [BlocBaseProviderMixin].
|
||||
/// Short hand for `context.read<AnotherBloc>();`
|
||||
///
|
||||
///
|
||||
/// To get [BlocBase] used by by this [BlocBaseProviderMixin] see `bloc()`
|
||||
AnotherBloc anotherBloc<AnotherBloc>(BuildContext context) =>
|
||||
context.read<AnotherBloc>();
|
||||
|
||||
@@ -21,7 +21,7 @@ import 'package:flutter_bloc/flutter_bloc.dart' as blocbase;
|
||||
/// of helper methods for events.
|
||||
mixin BlocProviderMixin<Bloc extends blocbase.Bloc<Event, Object>, Event> {
|
||||
/// Add an event to the [Bloc].
|
||||
///
|
||||
///
|
||||
/// Short hand for `context.read<Bloc>().add(event)`.
|
||||
void add(BuildContext context, Event event) =>
|
||||
context.read<Bloc>().add(event);
|
||||
|
||||
@@ -18,14 +18,14 @@ import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
/// {@template multi_provider}
|
||||
/// Merges [MultiRepositoryProvider] and [MultiBlocProvider] widgets into
|
||||
/// Merges [MultiRepositoryProvider] and [MultiBlocProvider] widgets into
|
||||
/// one widget tree.
|
||||
///
|
||||
/// [MultiProvider] improves the readability and eliminates the need
|
||||
/// to nest multiple providers.
|
||||
///
|
||||
/// By using [MultiProvider] we can go from:
|
||||
///
|
||||
///
|
||||
/// ```dart
|
||||
/// MultiRepositoryProvider(
|
||||
/// providers: [
|
||||
@@ -69,7 +69,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
/// )
|
||||
/// ```
|
||||
///
|
||||
/// [MultiProvider] converts the [RepositoryProvider] and [BlocProvider] lists
|
||||
/// [MultiProvider] converts the [RepositoryProvider] and [BlocProvider] lists
|
||||
/// into a tree of nested provider widgets.
|
||||
/// As a result, the only advantage of using [MultiProvider] is
|
||||
/// improved readability due to the reduction in nesting and boilerplate.
|
||||
|
||||
Reference in New Issue
Block a user