AppFlowy/app_flowy/lib/startup/tasks/application_task.dart

51 lines
1.4 KiB
Dart
Raw Normal View History

2021-06-19 15:41:19 +00:00
import 'package:app_flowy/startup/startup.dart';
2021-07-13 00:47:26 +00:00
import 'package:flowy_infra/theme.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
2021-06-19 15:41:19 +00:00
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:window_size/window_size.dart';
import 'package:app_flowy/startup/launch.dart';
class AppWidgetTask extends LaunchTask {
@override
LaunchTaskType get type => LaunchTaskType.appLauncher;
@override
2021-07-12 15:27:58 +00:00
Future<void> initialize(LaunchContext context) {
2021-06-19 15:41:19 +00:00
final widget = context.getIt<AppFactory>().create();
final app = ApplicationWidget(child: widget);
2021-06-19 15:41:19 +00:00
runApp(app);
2021-07-12 15:27:58 +00:00
return Future(() => {});
2021-06-19 15:41:19 +00:00
}
}
class ApplicationWidget extends StatelessWidget {
2021-06-19 15:41:19 +00:00
final Widget child;
const ApplicationWidget({
2021-06-19 15:41:19 +00:00
Key? key,
required this.child,
}) : super(key: key);
@override
Widget build(BuildContext context) {
setWindowMinSize(const Size(500, 500));
final theme = AppTheme.fromType(ThemeType.light);
return Provider.value(
value: theme,
child: MaterialApp(
builder: overlayManagerBuilder(),
2021-06-19 15:41:19 +00:00
debugShowCheckedModeBanner: false,
theme: theme.themeData,
navigatorKey: AppGlobals.rootNavKey,
home: child,
));
}
}
class AppGlobals {
static GlobalKey<NavigatorState> rootNavKey = GlobalKey();
static NavigatorState get nav => rootNavKey.currentState!;
}