1
0
mirror of https://github.com/flutter/samples.git synced 2026-04-02 09:43:05 +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

@@ -1,7 +1,29 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
.packages
.pub/
build/

View File

@@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.
version:
revision: b6d56a29dd482f596c3ddf937340c918154da871
channel: master
revision: 77d935af4db863f6abd0b9c31c7e6df2a13de57b
channel: stable
project_type: plugin

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'

View File

@@ -157,5 +157,5 @@ packages:
source: hosted
version: "2.1.1"
sdks:
dart: ">=2.14.0 <3.0.0"
flutter: ">=1.20.0"
dart: ">=2.15.1 <3.0.0"
flutter: ">=2.5.0"

View File

@@ -1,11 +1,11 @@
name: federated_plugin_macos
description: macOS implementation of federated_plugin to retrieve current battery level.
version: 0.0.1
publish_to: none
homepage:
environment:
sdk: ">=2.12.0 <3.0.0"
flutter: ">=1.20.0"
sdk: ">=2.15.1 <3.0.0"
flutter: ">=2.5.0"
dependencies:
flutter: