1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-10 14:58:34 +00:00

Update federated_plugin runners (#972)

This commit is contained in:
Brett Morgan
2022-01-05 12:35:50 +11:00
committed by GitHub
parent 26d88f1799
commit 9102cb4653
79 changed files with 678 additions and 687 deletions

View File

@@ -16,22 +16,22 @@ public class FederatedPluginMacosPlugin: NSObject, FlutterPlugin {
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method {
case "getBatteryLevel":
getBatteryLevel(result)
getBatteryLevel(result)
default:
result(FlutterMethodNotImplemented)
}
}
private func getBatteryLevel(_ result: FlutterResult) {
let snapshot = IOPSCopyPowerSourcesInfo().takeRetainedValue()
let sources = IOPSCopyPowerSourcesList(snapshot).takeRetainedValue() as Array
let sourceInfo : NSDictionary = IOPSGetPowerSourceDescription(snapshot, sources[0]).takeUnretainedValue()
guard let capacity = sourceInfo[kIOPSCurrentCapacityKey] as? Int else {
result(FlutterError(code: "STATUS_UNAVAILABLE", message: "Not able to determine battery level", details: nil))
return
}
result(capacity)
private func getBatteryLevel(_ result: FlutterResult) {
let snapshot = IOPSCopyPowerSourcesInfo().takeRetainedValue()
let sources = IOPSCopyPowerSourcesList(snapshot).takeRetainedValue() as Array
let sourceInfo : NSDictionary = IOPSGetPowerSourceDescription(snapshot, sources[0]).takeUnretainedValue()
guard let capacity = sourceInfo[kIOPSCurrentCapacityKey] as? Int else {
result(FlutterError(code: "STATUS_UNAVAILABLE", message: "Not able to determine battery level", details: nil))
return
}
result(capacity)
}
}

View File

@@ -1,6 +1,6 @@
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint federated_plugin_macos.podspec' to validate before publishing.
# Run `pod lib lint federated_plugin_macos.podspec` to validate before publishing.
#
Pod::Spec.new do |s|
s.name = 'federated_plugin_macos'