diff --git a/example/lib/main.dart b/example/lib/main.dart index e4a55a1a..0b47da07 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -7,7 +7,7 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_blue/flutter_blue.dart'; -import 'package:flutter_blue_example/widgets.dart'; +import 'widgets.dart'; void main() { runApp(FlutterBlueApp()); @@ -54,7 +54,7 @@ class BluetoothOffScreen extends StatelessWidget { 'Bluetooth Adapter is ${state != null ? state.toString().substring(15) : 'not available'}.', style: Theme.of(context) .primaryTextTheme - .subhead + .subtitle1 ?.copyWith(color: Colors.white), ), ], diff --git a/example/lib/widgets.dart b/example/lib/widgets.dart index aefdf262..23ae5949 100644 --- a/example/lib/widgets.dart +++ b/example/lib/widgets.dart @@ -135,7 +135,7 @@ class ServiceTile extends StatelessWidget { children: [ Text('Service'), Text('0x${service.uuid.toString().toUpperCase().substring(4, 8)}', - style: Theme.of(context).textTheme.body1?.copyWith( + style: Theme.of(context).textTheme.bodyText1?.copyWith( color: Theme.of(context).textTheme.caption?.color)) ], ), @@ -183,7 +183,7 @@ class CharacteristicTile extends StatelessWidget { Text('Characteristic'), Text( '0x${characteristic.uuid.toString().toUpperCase().substring(4, 8)}', - style: Theme.of(context).textTheme.body1?.copyWith( + style: Theme.of(context).textTheme.bodyText1?.copyWith( color: Theme.of(context).textTheme.caption?.color)) ], ), @@ -245,7 +245,7 @@ class DescriptorTile extends StatelessWidget { Text('0x${descriptor.uuid.toString().toUpperCase().substring(4, 8)}', style: Theme.of(context) .textTheme - .body1 + .bodyText1 ?.copyWith(color: Theme.of(context).textTheme.caption?.color)) ], ), @@ -289,11 +289,11 @@ class AdapterStateTile extends StatelessWidget { child: ListTile( title: Text( 'Bluetooth adapter is ${state.toString().substring(15)}', - style: Theme.of(context).primaryTextTheme.subhead, + style: Theme.of(context).primaryTextTheme.subtitle1, ), trailing: Icon( Icons.error, - color: Theme.of(context).primaryTextTheme.subhead?.color, + color: Theme.of(context).primaryTextTheme.subtitle1?.color, ), ), ); diff --git a/lib/src/bluetooth_device.dart b/lib/src/bluetooth_device.dart index ca3bb9ba..01961b0b 100644 --- a/lib/src/bluetooth_device.dart +++ b/lib/src/bluetooth_device.dart @@ -22,6 +22,7 @@ class BluetoothDevice { Duration? timeout, bool autoConnect = true, }) async { + final completer = Completer(); var request = protos.ConnectRequest.create() ..remoteId = id.toString() ..androidAutoConnect = autoConnect; @@ -30,7 +31,8 @@ class BluetoothDevice { if (timeout != null) { timer = Timer(timeout, () { disconnect(); - throw TimeoutException('Failed to connect in time.', timeout); + completer.completeError( + TimeoutException('Failed to connect in time.', timeout)); }); } @@ -41,7 +43,9 @@ class BluetoothDevice { timer?.cancel(); - return; + completer.complete(); + + return completer.future; } /// Cancels connection to the Bluetooth Device diff --git a/pubspec.yaml b/pubspec.yaml index 220c089d..f000666d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: flutter_blue description: Flutter plugin for connecting and communicating with Bluetooth Low Energy devices, on Android and iOS -version: 0.8.0 +version: 0.8.1 homepage: https://github.com/pauldemarco/flutter_blue environment: