focus-flow/apps/focus_flow_flutter/lib/main.dart

52 lines
1.6 KiB
Dart

// SPDX-FileCopyrightText: 2026 FocusFlow contributors
// SPDX-License-Identifier: AGPL-3.0-only
/// Launches the FocusFlow Flutter desktop application.
library;
import 'package:flutter/material.dart';
import 'app/focus_flow_app.dart';
import 'app/persistent_scheduler_composition.dart';
export 'app/demo_scheduler_composition.dart';
export 'app/focus_flow_app.dart';
export 'app/persistent_scheduler_composition.dart';
/// Starts the FocusFlow app with the persistent SQLite scheduler composition.
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
try {
final composition = await PersistentSchedulerComposition.open();
runApp(FocusFlowApp(composition: composition));
} on Object catch (error) {
runApp(_StartupFailureApp(message: error.toString()));
}
}
/// Minimal failure app shown when persistent startup cannot finish.
class _StartupFailureApp extends StatelessWidget {
/// Creates a startup failure app with [message].
const _StartupFailureApp({required this.message});
/// Diagnostic startup failure message.
final String message;
/// Builds the widget subtree for this component.
/// The method translates the current widget configuration and state into Flutter UI without mutating scheduler domain data.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'FocusFlow',
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: Padding(
padding: const EdgeInsets.all(24),
child: Text('Unable to open local schedule data.\n$message'),
),
),
),
);
}
}