57 lines
1.9 KiB
Dart
Raw Normal View History

2024-10-02 14:02:45 +04:00
import 'dart:io';
2024-09-06 20:59:47 +04:00
import 'package:flutter/material.dart';
2024-09-25 14:35:14 +04:00
import 'package:flutter_bloc/flutter_bloc.dart';
2024-10-02 14:02:45 +04:00
import 'package:lab/components/l10n/app_locale.dart';
2024-12-08 19:17:00 +04:00
import 'package:lab/data/repositories/futurama_repository.dart';
2024-10-02 14:02:45 +04:00
import 'package:lab/presentation/other/like_bloc/like_bloc.dart';
import 'package:lab/presentation/other/locale_bloc/locale_bloc.dart';
import 'package:lab/presentation/other/locale_bloc/locale_state.dart';
import 'package:lab/presentation/pages/home_page/home_page.dart';
import 'package:lab/presentation/pages/home_page/bloc/bloc.dart';
2024-09-06 20:59:47 +04:00
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
2024-09-06 21:09:15 +04:00
@override
2024-09-06 20:59:47 +04:00
Widget build(BuildContext context) {
2024-10-02 14:02:45 +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',
debugShowCheckedModeBanner: false,
localizationsDelegates: AppLocale.localizationsDelegates,
supportedLocales: AppLocale.supportedLocales,
locale: state.currentLocale,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.white),
useMaterial3: true,
),
2024-12-08 19:17:00 +04:00
home: RepositoryProvider<FuturamaRepository>(
2024-10-02 14:02:45 +04:00
lazy: true,
2024-12-08 19:17:00 +04:00
create: (_) => FuturamaRepository(),
2024-10-02 14:02:45 +04:00
child: BlocProvider<LikeBloc>(
lazy: false,
create: (context) => LikeBloc(),
child: BlocProvider<HomeBloc>(
lazy: false,
2024-12-08 19:17:00 +04:00
create: (context) =>
HomeBloc(context.read<FuturamaRepository>()),
child: const MyHomePage(title: 'Course work'),
2024-10-02 14:02:45 +04:00
),
),
),
);
},
2024-09-25 14:35:14 +04:00
),
2024-09-06 20:59:47 +04:00
);
}
}