Implementation
static Future<void> launch(BuildContext context, Model model) async {
final WindowController window = await DesktopMultiWindow.createWindow('');
await window.setFrame(const Offset(0, 0) & const Size(600, 720));
await window.center();
await window.setTitle('JRPN Calculator Internals');
await window.show();
late final void Function(void) observerRef;
bool hasLaunched = false;
void observer(void _) async {
try {
await DesktopMultiWindow.invokeMethod(
window.windowId, 'frob', model.internalSnapshot.value.text);
hasLaunched = true;
} catch (ex) {
if (hasLaunched) {
model.internalSnapshot.removeObserver(observerRef);
model.optimizeInternalSnapshot();
hasLaunched = false;
}
}
}
observerRef = observer;
model.internalSnapshot.addObserver(observerRef);
}