PIbd-31_Yakovlev.M.G._PMU/lib/main.dart

56 lines
1.9 KiB
Dart

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart%20%20';
import 'package:pmu_labs/components/locale/l10n/app_locale.dart';
import 'package:pmu_labs/data/repositories/bosses_repository.dart';
import 'package:pmu_labs/presentation/home_page/bloc/bloc.dart';
import 'package:pmu_labs/presentation/like_bloc/like_bloc.dart';
import 'package:pmu_labs/presentation/locale_bloc/locale_bloc.dart';
import 'package:pmu_labs/presentation/locale_bloc/locale_state.dart';
import 'presentation/home_page/home_page.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
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.deepPurpleAccent),
useMaterial3: true,
),
home: RepositoryProvider<BossesRepository>(
lazy: true,
create: (_) => BossesRepository(),
child: BlocProvider<LikeBloc>(
lazy: false,
create: (context) => LikeBloc(),
child: BlocProvider<HomeBloc>(
lazy: false,
create: (context) => HomeBloc(context.read<BossesRepository>()),
child: const MyHomePage(title: 'Боссы Sekiro'),
),
),
),
);
}
),
);
}
}