Unable to run the project for android device in my local machine #89
Description
D/FlutterLocationService(26426): Creating service.
D/FlutterLocationService(26426): Binding to location service.
E/flutter (26426): [ERROR:flutter/runtime/dart_isolate.cc(144)] Could not prepare isolate.
E/flutter (26426): [ERROR:flutter/runtime/runtime_controller.cc(462)] Could not create root isolate.
E/flutter (26426): [ERROR:flutter/shell/common/shell.cc(669)] Could not launch engine with configuration.
import 'dart:async';
import 'package:enough_platform_widgets/enough_platform_widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'account/provider.dart';
import 'app_lifecycle/provider.dart';
import 'background/provider.dart';
import 'keys/service.dart';
import 'localization/app_localizations.g.dart';
import 'lock/provider.dart';
import 'logger.dart';
import 'notification/service.dart';
import 'routes/provider.dart';
import 'routes/routes.dart';
import 'scaffold_messenger/service.dart';
import 'screens/screens.dart';
import 'settings/provider.dart';
import 'settings/theme/provider.dart';
import 'share/provider.dart';
// AppStyles appStyles = AppStyles.instance;
void main() {
runApp(const InitializationScreen());
}
/// Runs the app
class EnoughMailApp extends HookConsumerWidget {
/// Creates a new app
const EnoughMailApp({
super.key,
required this.appName,
});
final String appName;
@OverRide
Widget build(BuildContext context, WidgetRef ref) {
useOnAppLifecycleStateChange((previous, current) {
logger.d('raw AppLifecycleState changed from $previous to $current');
ref.read(rawAppLifecycleStateProvider.notifier).state = current;
});
final themeSettingsData = ref.watch(themeFinderProvider(context: context));
final languageTag =
ref.watch(settingsProvider.select((settings) => settings.languageTag));
final routerConfig = ref.watch(routerConfigProvider);
ref
..watch(incomingShareProvider)
..watch(backgroundProvider)
..watch(appLockProvider);
final app = Theme(
data: themeSettingsData.brightness == Brightness.dark
? themeSettingsData.darkTheme
: themeSettingsData.lightTheme,
child: PlatformSnackApp.router(
supportedLocales: AppLocalizations.supportedLocales,
localizationsDelegates: AppLocalizations.localizationsDelegates,
debugShowCheckedModeBanner: false,
title: appName,
routerConfig: routerConfig,
scaffoldMessengerKey:
ScaffoldMessengerService.instance.scaffoldMessengerKey,
materialTheme: themeSettingsData.lightTheme,
materialDarkTheme: themeSettingsData.darkTheme,
materialThemeMode: themeSettingsData.themeMode,
cupertinoTheme: themeSettingsData.cupertinoTheme,
),
);
if (languageTag == null) {
return app;
}
return Localizations.override(
context: context,
locale: Locale(languageTag),
child: app,
);
}
}
/// Initializes the app
class InitializationScreen extends ConsumerStatefulWidget {
/// Creates a new [InitializationScreen]
const InitializationScreen({super.key});
@OverRide
ConsumerState createState() =>
_InitializationScreenState();
}
class _InitializationScreenState extends ConsumerState {
@OverRide
void initState() {
_initApp();
super.initState();
}
Future _initApp() async {
await ref.read(settingsProvider.notifier).init();
await ref.read(realAccountsProvider.notifier).init();
// await ref.read(backgroundProvider.notifier).init();
if (context.mounted) {
// TODO(RV): check if the context is really needed for NotificationService
await NotificationService.instance.init(context: context);
}
await KeyService.instance.init();
logger.d('App initialized');
if (context.mounted) {
if (ref.read(allAccountsProvider).isEmpty) {
context.goNamed(Routes.welcome);
} else {
context.goNamed(Routes.mail);
}
}
}
@OverRide
Widget build(BuildContext context) => const SplashScreen();
}
added this by me
void main() {
runApp(const InitializationScreen());
}