mirror of
https://github.com/salvadordeveloper/flutter-crypto-app.git
synced 2025-05-17 10:25:53 +08:00
44 lines
1.4 KiB
Dart
44 lines
1.4 KiB
Dart
import 'package:cryptocurrency_app/constants/app_theme.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
|
import 'provider/settings_provider.dart';
|
|
import 'ui/home.dart';
|
|
import 'package:cryptocurrency_app/constants/utils.dart' as Utils;
|
|
|
|
void main() async {
|
|
await dotenv.load(fileName: ".env");
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
await EasyLocalization.ensureInitialized();
|
|
|
|
runApp(EasyLocalization(
|
|
supportedLocales: [Locale('en'), Locale('es')],
|
|
path: 'assets/translations',
|
|
fallbackLocale: Locale('en'),
|
|
child: ProviderScope(child: MyApp())));
|
|
}
|
|
|
|
class MyApp extends HookConsumerWidget {
|
|
MyApp({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final settings = ref.watch(cryptoSettings);
|
|
|
|
final themeMode = settings.maybeWhen(
|
|
data: (data) => Utils.getThemeMode(data.themeMode),
|
|
orElse: () => ThemeMode.system);
|
|
|
|
return MaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
localizationsDelegates: context.localizationDelegates,
|
|
supportedLocales: context.supportedLocales,
|
|
locale: context.locale,
|
|
home: Home(),
|
|
themeMode: themeMode,
|
|
theme: AppTheme.light,
|
|
darkTheme: AppTheme.dark);
|
|
}
|
|
}
|