2024-09-09 23:59:15 +04:00
|
|
|
|
import 'package:flutter/material.dart';
|
2024-11-19 23:39:56 +04:00
|
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
|
import 'package:mobiles_labs_5th_semester/data/repositories/games_repository.dart';
|
|
|
|
|
import 'package:mobiles_labs_5th_semester/presentation/home_page/bloc/bloc.dart';
|
2024-09-09 23:59:15 +04:00
|
|
|
|
|
2024-10-29 18:39:40 +04:00
|
|
|
|
import 'presentation/home_page/home_page.dart';
|
|
|
|
|
|
2024-09-09 23:59:15 +04:00
|
|
|
|
void main() {
|
|
|
|
|
runApp(const MyApp());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
|
const MyApp({super.key});
|
|
|
|
|
|
2024-10-02 22:44:53 +04:00
|
|
|
|
@override
|
2024-09-09 23:59:15 +04:00
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return MaterialApp(
|
|
|
|
|
title: 'Flutter Demo',
|
2024-09-10 00:10:35 +04:00
|
|
|
|
debugShowCheckedModeBanner: false,
|
2024-11-19 23:39:56 +04:00
|
|
|
|
home: RepositoryProvider<GamesRepository>(
|
|
|
|
|
//репозиторий будет создан только тогда, когда будет запрошен, а не сразу при создании виджета
|
|
|
|
|
lazy: true,
|
|
|
|
|
create: (_) => GamesRepository(),
|
|
|
|
|
child: BlocProvider(
|
|
|
|
|
//bloc будет создан сразу при создании виджета
|
|
|
|
|
lazy: false,
|
|
|
|
|
//context нужен, чтобы суметь обратиться к провайдеру, кот. выше по дереву
|
|
|
|
|
create: (context) => HomeBloc(context.read<GamesRepository>()),
|
|
|
|
|
child: const HomePage(title: 'Чернышев Георгий Янович'),
|
|
|
|
|
),
|
|
|
|
|
)
|
2024-09-09 23:59:15 +04:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-02 22:44:53 +04:00
|
|
|
|
|