You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.2 KiB
60 lines
2.2 KiB
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
import 'package:hadi_hoda_flutter/common_ui/theme/my_theme.dart';
|
|
import 'package:hadi_hoda_flutter/common_ui/theme/theme_service.dart';
|
|
import 'package:hadi_hoda_flutter/core/constants/my_constants.dart';
|
|
import 'package:hadi_hoda_flutter/core/routers/my_routes.dart';
|
|
import 'package:hadi_hoda_flutter/core/utils/app_life_cycle.dart';
|
|
import 'package:hadi_hoda_flutter/core/utils/local_storage.dart';
|
|
import 'package:hadi_hoda_flutter/core/utils/my_device.dart';
|
|
import 'package:hadi_hoda_flutter/core/utils/storage_path.dart';
|
|
import 'package:hadi_hoda_flutter/features/app/presentation/bloc/app_bloc.dart';
|
|
import 'package:hadi_hoda_flutter/features/app/presentation/bloc/app_event.dart';
|
|
import 'package:hadi_hoda_flutter/init_bindings.dart';
|
|
import 'package:hadi_hoda_flutter/l10n/app_localizations.dart';
|
|
|
|
import 'features/app/presentation/bloc/app_state.dart';
|
|
|
|
Future<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
AppLifeCycleController();
|
|
initBindings();
|
|
await Future.wait([
|
|
LocalStorage.init(),
|
|
StoragePath.getDocumentDir(),
|
|
initDataBase(),
|
|
MyDevice.setPortrait(),
|
|
MyDevice.setImmersiveSticky(),
|
|
]);
|
|
runApp(const MainApp());
|
|
}
|
|
|
|
class MainApp extends StatelessWidget {
|
|
const MainApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocProvider(
|
|
create: (context) => locator<AppBloc>()..add(InitLocaleEvent()),
|
|
child: BlocBuilder<AppBloc, AppState>(
|
|
builder: (context, state) => MaterialApp.router(
|
|
theme: MyTheme.light,
|
|
darkTheme: MyTheme.dark,
|
|
themeMode: ThemeService.getTheme(),
|
|
locale: state.locale,
|
|
supportedLocales: MyConstants.languages.map(
|
|
(e) => e.locale ?? Locale('en', 'US'),
|
|
),
|
|
routerConfig: appPages,
|
|
localizationsDelegates: const [
|
|
AppLocalizations.delegate,
|
|
GlobalMaterialLocalizations.delegate,
|
|
GlobalWidgetsLocalizations.delegate,
|
|
GlobalCupertinoLocalizations.delegate,
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|