Skip to content

Commit

Permalink
Only set the log level *if* bluetooth is available. (pauldemarco#288)
Browse files Browse the repository at this point in the history
* Only set the log level *if* bluetooh is available. Otherwise, setLogLevel throws a PlatformException.

* Update changelog and bumped version.

* Removed changelog and version update based on feedback because ‾\_(ツ)_/‾
  • Loading branch information
efortuna authored Apr 8, 2020
1 parent 04f5596 commit df44e5c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/src/flutter_blue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class FlutterBlue {
return;
});

// Send the log level to the underlying platforms.
setLogLevel(logLevel);
_setLogLevelIfAvailable();
}

static FlutterBlue _instance = new FlutterBlue._();
static FlutterBlue get instance => _instance;

Expand Down Expand Up @@ -65,6 +65,13 @@ class FlutterBlue {
.then((p) => p.devices)
.then((p) => p.map((d) => BluetoothDevice.fromProto(d)).toList());
}

_setLogLevelIfAvailable() async {
if (await isAvailable) {
// Send the log level to the underlying platforms.
setLogLevel(logLevel);
}
}

/// Starts a scan for Bluetooth Low Energy devices
/// Timeout closes the stream after a specified [Duration]
Expand Down

0 comments on commit df44e5c

Please sign in to comment.