Skip to main content
CLI Setup: If you create a new Neo project using the Neo CLI, NeoApp will be fully configured for you inside main.dart with proper initialization, theming, and routing setup.
Placement Note: While currently categorized under utilities, NeoApp may be reorganized into a more appropriate category in future releases as we refine our documentation structure and terminology.

Example

import 'package:flutter/widgets.dart';
import 'package:neo/neo.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

import 'router/neo_router.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  NeoInitializer.initialize().then((_) {
    runApp(
      ProviderScope(
        child: MyApp(),
      ),
    );
  });
}

class MyApp extends ConsumerWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final neoRouter = ref.watch(routerProvider);

    return NeoApp(
      title: "My Neo App",
      routerConfig: neoRouter.config(),
    );
  }
}

Properties

Required

title
String
required
The title of the application. Used by the operating system to identify your app (e.g., in the task switcher) and as the browser tab title on web platforms.
routerConfig
RouterConfig<Object>
required
The router configuration for navigation. Typically an AutoRouter configuration from the auto_route package that defines your app’s routes and navigation structure.

Theming

defaultThemeMode
NeoThemeMode
default:"NeoThemeMode.system"
The initial theme mode to use when the app starts.
defaultLightTheme
NeoThemeBase
default:"NeoThemeLight()"
Custom light theme to use instead of the default Neo theme.
defaultDarkTheme
NeoThemeBase
default:"NeoThemeDark()"
Custom dark theme to use instead of the default Neo theme.

Enums

NeoThemeMode

Controls how the app determines which theme to use.
  • system: Automatically switches between light and dark themes based on the device’s system setting. Responds to system-level theme changes in real-time.
  • light: Always uses the light theme regardless of system settings.
  • dark: Always uses the dark theme regardless of system settings.

Best Practices

  • Riverpod Required: NeoApp requires ProviderScope as an ancestor widget for state management. Wrap your app with ProviderScope in your main() function.

Integration Notes

  • Initialization: NeoApp works with NeoInitializer.initialize() to properly set up the Neo framework before the app starts.
I