window_manager
window_manager copied to clipboard
quitting app on macos throws error
flutter run -d macos
Launching lib/main.dart on macOS in debug mode...
Building macOS application...
2023-11-21 09:44:41.693 xcodebuild[32238:4521379] DVTCoreDeviceEnabledState: DVTCoreDeviceEnabledState_Disabled set via user default (DVTEnableCoreDevice=disabled)
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, arch:arm64, id:00008103-000164463A40801E }
{ platform:macOS, arch:x86_64, id:00008103-000164463A40801E }
Syncing files to device macOS... 78ms
Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).
A Dart VM Service on macOS is available at: http://127.0.0.1:56188/nB5DWYQ9jvg=/
The Flutter DevTools debugger and profiler on macOS is available at: http://127.0.0.1:9101?uri=http://127.0.0.1:56188/nB5DWYQ9jvg=/
Lost connection to device.
embedder.cc (2562): 'FlutterPlatformMessageCreateResponseHandle' returned 'kInvalidArguments'. Engine handle was invalid.
2023-11-21 09:44:50.891 ui_test[32378:4521911] Failed to create a FlutterPlatformMessageResponseHandle (2)
Minimal code to reproduce:
import 'package:flutter/material.dart';
import 'package:window_manager/window_manager.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await windowManager.ensureInitialized();
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> with WindowListener {
late AppLifecycleListener listener;
@override
void initState() {
super.initState();
windowManager.addListener(this);
_initWindowManager();
}
@override
void onWindowClose() async {
bool isPreventClose = await windowManager.isPreventClose();
if (isPreventClose) {
windowManager.destroy();
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(home: Scaffold(appBar: AppBar()));
}
void _initWindowManager() async {
await windowManager.setPreventClose(true);
setState(() {});
}
@override
void dispose() {
listener.dispose();
windowManager.removeListener(this);
super.dispose();
}
}
non-issue
@damywise can you explain in detail what you mean by non-issue?
was it not reproducible?
The error is not an issue, literally. There's no problem there. No side effects. It's normal. Happens all the time. Just ignore it. Unless there's an unexpected problem/behavior which you haven't specified.
see also https://github.com/flutter/flutter/issues/138707