flutter_desktop_sleep

Last updated:

0 purchases

flutter_desktop_sleep Image
flutter_desktop_sleep Images
Add to Cart

Description:

flutter desktop sleep

flutter_desktop_sleep #
2022 © Bikramaditya Meher

flutter_window_sleep lets you know your Flutter app if app going to close/sleep/wakeup and has a
chance to confirm if the user want to close there running task such as logout function, etc. It
works on desktop platforms including Windows and macOS. Thanks
to [flutter_window_close] (https://pub.dartlang.org/packages/flutter_window_close) it was help me
very much.


Example #
FlutterDesktopSleep flutterDesktopSleep = FlutterDesktopSleep();
flutterDesktopSleep.setWindowSleepHandler((String? s) async {
Get.log('dsfsadf $s');
if (s != null) {
// autoClockOff(note: s, shouldThread: false, shouldOn: true);
if (s == 'sleep') {
autoClockOff(note: 'Laptop sleep', shouldOn: false);
} else if (s == 'woke_up') {
autoClockOff(note: 'Laptop woke up', shouldOn: true);
} else if (s == 'terminate_app') {
await autoClockOff(
note: 'App Terminate', shouldThread: false, shouldOn: false);
flutterDesktopSleep.terminateApp();
}
}
});
copied to clipboard
macOS #
For macOs you need to add following code to your macos/Runner/AppDelegate.swift
import Cocoa
import FlutterMacOS
import Firebase
import flutter_desktop_sleep

@NSApplicationMain
class AppDelegate: FlutterAppDelegate {
var _windowManager = FlutterDesktopSleepPlugin()
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
}
override func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
let controller : FlutterViewController = mainFlutterWindow?.contentViewController as! FlutterViewController
return _windowManager.applicationShouldTerminate(controller);
}
}

copied to clipboard
Windows #
no need any setup just

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.