leanflutter / window_manager

This plugin allows Flutter desktop apps to resizing and repositioning the window.
https://pub.dev/packages/window_manager
MIT License
676 stars 177 forks source link

quitting app on macos throws error #420

Closed ujwalbasnet1 closed 1 month ago

ujwalbasnet1 commented 7 months ago
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();
  }
}
damywise commented 7 months ago

non-issue

ujwalbasnet1 commented 7 months ago

@damywise can you explain in detail what you mean by non-issue?

was it not reproducible?

damywise commented 7 months ago

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.

IvoB1987 commented 3 months ago

see also https://github.com/flutter/flutter/issues/138707

lijy91 commented 1 month ago

It doesn't seem to be caused by window_manager.

see also flutter/flutter#138707