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.
selfprivacy.org.app/lib/main.dart

65 lines
2.1 KiB

2 years ago
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
2 years ago
import 'package:selfprivacy/config/hive_config.dart';
import 'package:selfprivacy/ui/pages/initializing/initializing.dart';
2 years ago
import 'package:selfprivacy/ui/pages/onboarding/onboarding.dart';
import 'package:easy_localization/easy_localization.dart';
2 years ago
import 'package:selfprivacy/ui/pages/rootRoute.dart';
2 years ago
import 'package:wakelock/wakelock.dart';
2 years ago
import 'config/bloc_config.dart';
import 'config/bloc_observer.dart';
2 years ago
import 'config/brand_theme.dart';
2 years ago
import 'config/get_it_config.dart';
import 'config/localization.dart';
2 years ago
import 'logic/cubit/app_settings/app_settings_cubit.dart';
2 years ago
final navigatorKey = GlobalKey<NavigatorState>();
2 years ago
void main() async {
await HiveConfig.init();
Bloc.observer = SimpleBlocObserver(navigatorKey: navigatorKey);
2 years ago
Wakelock.enable();
2 years ago
getItSetup();
WidgetsFlutterBinding.ensureInitialized();
runApp(
Localization(
2 years ago
child: BlocAndProviderConfig(
child: MyApp(),
),
),
);
2 years ago
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
2 years ago
var appSettings = context.watch<AppSettingsCubit>().state;
2 years ago
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle.light, // Manually changnig appbar color
child: MaterialApp(
navigatorKey: navigatorKey,
localizationsDelegates: context.localizationDelegates,
supportedLocales: context.supportedLocales,
locale: context.locale,
2 years ago
debugShowCheckedModeBanner: false,
title: 'SelfPrivacy',
2 years ago
theme: appSettings.isDarkModeOn ? darkTheme : ligtTheme,
home: appSettings.isOnbordingShowing
? OnboardingPage(nextPage: InitializingPage())
: RootPage(),
builder: (BuildContext context, Widget widget) {
Widget error = Text('...rendering error...');
if (widget is Scaffold || widget is Navigator)
error = Scaffold(body: Center(child: error));
ErrorWidget.builder = (FlutterErrorDetails errorDetails) => error;
return widget;
},
2 years ago
),
);
}
}