Skip to content

Commit

Permalink
feat: Add macos support
Browse files Browse the repository at this point in the history
  • Loading branch information
bdlukaa committed Oct 11, 2024
1 parent 6714eeb commit 06d670b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions macos/Runner/MainFlutterWindow.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// This file was modified according to https://pub.dev/packages/launch_at_startup#macos-support

import Cocoa
import FlutterMacOS
import LaunchAtLogin // launch_at_startup

class MainFlutterWindow: NSWindow {
override func awakeFromNib() {
Expand All @@ -8,6 +11,26 @@ class MainFlutterWindow: NSWindow {
self.contentViewController = flutterViewController
self.setFrame(windowFrame, display: true)

// <launch_at_startup>
// Add FlutterMethodChannel platform code
FlutterMethodChannel(
name: "launch_at_startup", binaryMessenger: flutterViewController.engine.binaryMessenger
)
.setMethodCallHandler { (_ call: FlutterMethodCall, result: @escaping FlutterResult) in
switch call.method {
case "launchAtStartupIsEnabled":
result(LaunchAtLogin.isEnabled)
case "launchAtStartupSetEnabled":
if let arguments = call.arguments as? [String: Any] {
LaunchAtLogin.isEnabled = arguments["setEnabledValue"] as! Bool
}
result(nil)
default:
result(FlutterMethodNotImplemented)
}
}
// </launch_at_startup>

RegisterGeneratedPlugins(registry: flutterViewController)

super.awakeFromNib()
Expand Down

0 comments on commit 06d670b

Please sign in to comment.