Render startup immediately and defer native work with a smooth home transition
This commit is contained in:
+27
-15
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:timezone/data/latest.dart' as tzdata;
|
||||
@@ -25,21 +27,31 @@ Widget buildApplication(
|
||||
);
|
||||
Future<void> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
tzdata.initializeTimeZones();
|
||||
final selection = ValueNotifier<String?>(null);
|
||||
final gateway = PluginReminderGateway(onTap: (key) => selection.value = key);
|
||||
final controller = AppController(
|
||||
FileSnapshotStore(await getApplicationSupportDirectory()),
|
||||
LocalNotificationService(gateway),
|
||||
AndroidCalendarService(MethodCalendarGateway()),
|
||||
DateTime.now,
|
||||
);
|
||||
AppController? controller;
|
||||
await launchApplication(
|
||||
ready: controller.initialize(),
|
||||
child: buildApplication(
|
||||
controller,
|
||||
notificationSelection: selection,
|
||||
school: SchoolSession(),
|
||||
),
|
||||
bootstrap: () async {
|
||||
tzdata.initializeTimeZones();
|
||||
final selection = ValueNotifier<String?>(null);
|
||||
final gateway = PluginReminderGateway(
|
||||
onTap: (key) => selection.value = key,
|
||||
);
|
||||
final value = AppController(
|
||||
FileSnapshotStore(await getApplicationSupportDirectory()),
|
||||
LocalNotificationService(gateway),
|
||||
AndroidCalendarService(MethodCalendarGateway()),
|
||||
DateTime.now,
|
||||
);
|
||||
await value.initialize(reconcileServices: false);
|
||||
controller = value;
|
||||
return buildApplication(
|
||||
value,
|
||||
notificationSelection: selection,
|
||||
school: SchoolSession(),
|
||||
);
|
||||
},
|
||||
onHomeReady: () {
|
||||
final value = controller;
|
||||
if (value != null) unawaited(value.refreshServices());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user