Enable iOS use of platform channels (#8695)
Changed standard encoding to use host endianness. Engine roll.
This commit is contained in:
committed by
GitHub
parent
cbb495c16d
commit
898b6f8549
@@ -3,7 +3,6 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -19,15 +18,11 @@ class _PlatformServicesState extends State<PlatformServices> {
|
||||
|
||||
Future<Null> _getBatteryLevel() async {
|
||||
String batteryLevel;
|
||||
if (Platform.isIOS) {
|
||||
batteryLevel = "iOS is not supported yet.";
|
||||
} else {
|
||||
try {
|
||||
final int result = await platform.invokeMethod('getBatteryLevel');
|
||||
batteryLevel = 'Battery level at $result % .';
|
||||
} on PlatformException catch (e) {
|
||||
batteryLevel = "Failed to get battery level: '${e.message}'.";
|
||||
}
|
||||
try {
|
||||
final int result = await platform.invokeMethod('getBatteryLevel');
|
||||
batteryLevel = 'Battery level at $result % .';
|
||||
} on PlatformException catch (e) {
|
||||
batteryLevel = "Failed to get battery level: '${e.message}'.";
|
||||
}
|
||||
setState(() {
|
||||
_batteryLevel = batteryLevel;
|
||||
@@ -45,14 +40,14 @@ class _PlatformServicesState extends State<PlatformServices> {
|
||||
child: new Text('Get Battery Level'),
|
||||
onPressed: _getBatteryLevel,
|
||||
),
|
||||
new Text(_batteryLevel)
|
||||
new Text(_batteryLevel),
|
||||
],
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void main() {
|
||||
runApp(new PlatformServices());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user