70 lines
2.8 KiB
Dart

// 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/>.
import 'package:bloc_helper_example/counter/counter_bloc_page.dart';
import 'package:bloc_helper_example/counter/counter_consumer_page.dart';
import 'package:bloc_helper_example/counter/counter_cubit_page.dart';
import 'package:bloc_helper_example/counter/counter_provider_page.dart';
import 'package:bloc_helper_example/counter/cubit/counter_cubit.dart';
import 'package:bloc_helper_example/counter/repository/counter_repository.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class MainPage extends StatelessWidget {
const MainPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Main Page'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
child: const Text('Counter with BlocScreen'),
onPressed: () => Navigator.of(context).push(
MaterialPageRoute(builder: (_) => const CounterBlocPage())),
),
ElevatedButton(
child: const Text('Counter with CubitScreen'),
onPressed: () => Navigator.of(context).push(
MaterialPageRoute(builder: (_) => const CounterCubitPage())),
),
ElevatedButton(
child: const Text('Counter with BlocProviderScreen'),
onPressed: () => Navigator.of(context).push(MaterialPageRoute(
builder: (_) => const CounterProviderPage())),
),
ElevatedButton(
child: const Text('Counter with BlocConsumerScreen'),
onPressed: () => Navigator.of(context)
.push(MaterialPageRoute(builder: (context) {
return BlocProvider<CounterCubit>(
create: (context) => CounterCubit(context.read<CounterRepository>()),
child: const CounterConsumerPage(),
);
})),
),
],
),
),
);
}
}