Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run the project for android device in my local machine #89

Open
prakhar1032 opened this issue Feb 19, 2024 · 0 comments
Open

Comments

@prakhar1032
Copy link

prakhar1032 commented Feb 19, 2024

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());
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant