PIbd-32_Bulatova_K._R._PMU/lib/main.dart

56 lines
2.0 KiB
Dart
Raw Permalink Normal View History

2024-11-18 12:35:29 +04:00
import 'dart:io';
2024-09-18 17:00:02 +04:00
import 'package:flutter/material.dart';
import 'package:project1/presentation/home_page/home_page.dart';
2024-10-17 14:00:22 +04:00
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:project1/presentation/home_page/bloc/bloc.dart';
2024-11-18 12:35:29 +04:00
import 'package:project1/presentation/like_bloc/like_bloc.dart';
import 'package:project1/presentation/locale_bloc/locale_bloc.dart';
import 'package:project1/presentation/locale_bloc/locale_state.dart';
import 'components/locale/l10n/app_locale.dart';
2024-11-18 13:20:06 +04:00
import 'data/repositories/films_repository.dart';
2024-10-17 14:00:22 +04:00
import 'data/repositories/potter_repository.dart';
2024-09-18 17:00:02 +04:00
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
2024-09-22 21:49:20 +04:00
@override
2024-09-18 17:00:02 +04:00
Widget build(BuildContext context) {
2024-11-18 12:35:29 +04:00
return BlocProvider<LocaleBloc>(
lazy: false,
create: (context) => LocaleBloc(Locale(Platform.localeName)),
child: BlocBuilder<LocaleBloc, LocaleState>(
builder: (context, state) {
return MaterialApp(
title: 'Flutter Demo',
locale: state.currentLocale,
localizationsDelegates: AppLocale.localizationsDelegates,
supportedLocales: AppLocale.supportedLocales,
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
2024-11-18 13:20:06 +04:00
home: RepositoryProvider<FilmsRepository>(
2024-11-18 12:35:29 +04:00
lazy: true,
2024-11-18 13:20:06 +04:00
create: (_) => FilmsRepository(),
2024-11-18 12:35:29 +04:00
child: BlocProvider<LikeBloc>(
lazy: false,
create: (context) => LikeBloc(),
child: BlocProvider<HomeBloc>(
lazy: false,
2024-11-18 13:20:06 +04:00
create: (context) => HomeBloc(context.read<FilmsRepository>()),
2024-11-18 12:35:29 +04:00
child: const MyHomePage(title: 'Булатова Карина Раилевна'),
),
),
),
);
},
2024-10-17 14:00:22 +04:00
),
2024-09-18 17:00:02 +04:00
);
}
2024-11-18 12:35:29 +04:00
}