Skip to content

Commit

Permalink
Dart 2 compatibility. Fixes #51
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldemarco committed Apr 2, 2018
1 parent 8266b4a commit 69493c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
10 changes: 5 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class _FlutterBlueAppState extends State<FlutterBlueApp> {
.toList();
}

_buildDescriptorTile(BluetoothDescriptor d) {
Widget _buildDescriptorTile(BluetoothDescriptor d) {
var title = new Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down Expand Up @@ -251,7 +251,7 @@ class _FlutterBlueAppState extends State<FlutterBlueApp> {
);
}

_buildCharacteristicTile(BluetoothCharacteristic c) {
Widget _buildCharacteristicTile(BluetoothCharacteristic c) {
var descriptorTiles =
c.descriptors.map((d) => _buildDescriptorTile(d)).toList();
var actions = new Row(
Expand Down Expand Up @@ -308,7 +308,7 @@ class _FlutterBlueAppState extends State<FlutterBlueApp> {
}
}

_buildServiceTile(BluetoothService s) {
Widget _buildServiceTile(BluetoothService s) {
var characteristicsTiles = s.characteristics
.map((c) => _buildCharacteristicTile(c))
.toList();
Expand Down Expand Up @@ -338,7 +338,7 @@ class _FlutterBlueAppState extends State<FlutterBlueApp> {
}
}

_buildServiceTiles() {
List<Widget> _buildServiceTiles() {
return services.map((s) => _buildServiceTile(s)).toList();
}

Expand Down Expand Up @@ -389,7 +389,7 @@ class _FlutterBlueAppState extends State<FlutterBlueApp> {

@override
Widget build(BuildContext context) {
var tiles = new List();
var tiles = new List<Widget>();
if (state != BluetoothState.on) {
tiles.add(_buildAlertTile());
}
Expand Down
8 changes: 3 additions & 5 deletions lib/src/flutter_blue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class FlutterBlue {
}

/// Stops a scan for Bluetooth Low Energy devices
Future<Null> _stopScan() => _channel.invokeMethod('stopScan');
Future _stopScan() => _channel.invokeMethod('stopScan');

/// Establishes a connection to the Bluetooth Device.
/// Returns a stream of [BluetoothDeviceState]
Expand All @@ -104,7 +104,7 @@ class FlutterBlue {
var connected = false;
StreamSubscription subscription;
StreamController controller;
controller = new StreamController(
controller = new StreamController<BluetoothDeviceState>(
onListen: () {
if(timeout != null) {
new Future.delayed(timeout, () => (!connected) ? controller.close(): null);
Expand Down Expand Up @@ -134,9 +134,7 @@ class FlutterBlue {
}

/// Cancels connection to the Bluetooth Device
Future<Null> _cancelConnection(BluetoothDevice device) {
return _channel.invokeMethod('disconnect', device.id.toString());
}
Future _cancelConnection(BluetoothDevice device) => _channel.invokeMethod('disconnect', device.id.toString());
}

/// State of the bluetooth adapter.
Expand Down

0 comments on commit 69493c9

Please sign in to comment.