mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

Adds macOS support for `flutter create`: - Currently it is behind a hidden flag. - Adds a TargetPlatform workaround to lib/main.dart in the standard app template when enabled. - Supports `app` and `plugin`; `module` support doesn't yet exist for macOS in general. This will eliminate the need to use FDE's examples as templates on macOS. The templates are based on the current state of FDE's examples, with templating support added (and with adoption of the new application delegate in the app, which hadn't been done yet in FDE, eliminating some boilerplate from the template). Fixes #30703
20 lines
654 B
Cheetah
20 lines
654 B
Cheetah
import Cocoa
|
|
import FlutterMacOS
|
|
|
|
public class {{pluginClass}}: NSObject, FlutterPlugin {
|
|
public static func register(with registrar: FlutterPluginRegistrar) {
|
|
let channel = FlutterMethodChannel(name: "{{projectName}}", binaryMessenger: registrar.messenger)
|
|
let instance = {{pluginClass}}()
|
|
registrar.addMethodCallDelegate(instance, channel: channel)
|
|
}
|
|
|
|
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
|
switch call.method {
|
|
case "getPlatformVersion":
|
|
result("macOS " + ProcessInfo.processInfo.operatingSystemVersionString)
|
|
default:
|
|
result(FlutterMethodNotImplemented)
|
|
}
|
|
}
|
|
}
|