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.

74 lines
1.8 KiB

import 'package:flutter/material.dart';
import 'core/app_initializer.dart';
import 'core/app_services.dart';
import 'core/logger.dart';
import 'ui/navigation/main_navigation_scaffold.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// Determine environment
const String environment = String.fromEnvironment(
'ENV',
defaultValue: 'dev',
);
// Initialize all services
AppServices? appServices;
try {
appServices = await AppInitializer.initialize(environment: environment);
} catch (e, stackTrace) {
Logger.error('Failed to initialize application', e, stackTrace);
// App will show error state
}
runApp(MyApp(appServices: appServices));
}
/// The root widget of the application.
class MyApp extends StatefulWidget {
final AppServices? appServices;
const MyApp({super.key, this.appServices});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void dispose() {
// Dispose of all services
widget.appServices?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final appServices = widget.appServices;
return MaterialApp(
title: 'App Boilerplate',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
useMaterial3: true,
),
home: appServices != null
? const MainNavigationScaffold()
: const Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircularProgressIndicator(),
SizedBox(height: 16),
Text('Initializing application...'),
],
),
),
),
);
}
}

Powered by TurnKey Linux.