Skip to content

Commit

Permalink
Fix formatting issue from Dart Analysis (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikolak authored Dec 13, 2019
1 parent 57c004e commit 0ef7df7
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 29 deletions.
2 changes: 1 addition & 1 deletion lib/ble_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ abstract class CallbackType {
static const int allMatches = 1;
static const int firstMatch = 2;
static const int matchLost = 4;
}
}
3 changes: 2 additions & 1 deletion lib/characteristic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class CharacteristicWithValue extends Characteristic with WithValue {

@override
String toString() {
return super.toString() + ' CharacteristicWithValue{value = ${value.toString()}';
return super.toString() +
' CharacteristicWithValue{value = ${value.toString()}';
}
}
2 changes: 1 addition & 1 deletion lib/error/ble_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@ class BleErrorCode {
int value;

BleErrorCode(this.value);
}
}
3 changes: 2 additions & 1 deletion lib/internal/bridge/bluetooth_state_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ part of internal_bridge_lib;

mixin BluetoothStateMixin on FlutterBLE {
final Stream<dynamic> _adapterStateChanges =
const EventChannel(ChannelName.adapterStateChanges).receiveBroadcastStream();
const EventChannel(ChannelName.adapterStateChanges)
.receiveBroadcastStream();

Future<void> enableRadio(String transactionId) async {
await _methodChannel.invokeMethod(
Expand Down
13 changes: 12 additions & 1 deletion lib/internal/bridge/internal_bridge_lib.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,25 @@ import 'package:flutter_ble_lib/internal/util/transformers.dart';
import '../managers_for_classes.dart';

part '../base_entities.dart';

part '../internal_ble_manager.dart';

part 'bluetooth_state_mixin.dart';

part 'characteristics_mixin.dart';

part 'device_connection_mixin.dart';

part 'device_rssi_mixin.dart';

part 'devices_mixin.dart';

part 'discovery_mixin.dart';

part 'lib_core.dart';

part 'log_level_mixin.dart';

part 'mtu_mixin.dart';
part 'scanning_mixin.dart';

part 'scanning_mixin.dart';
5 changes: 3 additions & 2 deletions lib/internal/bridge/lib_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class FlutterBleLib extends FlutterBLE
DevicesMixin,
CharacteristicsMixin {
final Stream<dynamic> _restoreStateEvents =
const EventChannel(ChannelName.stateRestoreEvents).receiveBroadcastStream();
const EventChannel(ChannelName.stateRestoreEvents)
.receiveBroadcastStream();

void registerManager(InternalBleManager manager) {
_manager = manager;
Expand All @@ -32,7 +33,7 @@ class FlutterBleLib extends FlutterBLE
return null;
else {
List<Map<String, dynamic>> restoredPeripheralsJson =
(jsonDecode(jsonString) as List<dynamic>).cast();
(jsonDecode(jsonString) as List<dynamic>).cast();
return restoredPeripheralsJson
.map((peripheralJson) =>
Peripheral.fromJson(peripheralJson, _manager))
Expand Down
8 changes: 5 additions & 3 deletions lib/internal/bridge/log_level_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ mixin LogLevelMixin on FlutterBLE {
}

Future<LogLevel> logLevel() async {
String logLevelName = await _methodChannel.invokeMethod(MethodName.logLevel);
String logLevelName =
await _methodChannel.invokeMethod(MethodName.logLevel);
return _logLevelFromString(logLevelName);
}

LogLevel _logLevelFromString(String logLevelName) {
print("try to get log level from: $logLevelName");
return LogLevel.values.firstWhere((e) => e.toString() == 'LogLevel.' + logLevelName.toLowerCase());
return LogLevel.values.firstWhere(
(e) => e.toString() == 'LogLevel.' + logLevelName.toLowerCase());
}
}
}
2 changes: 1 addition & 1 deletion lib/internal/bridge/mtu_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ mixin MtuMixin on FlutterBLE {
}).catchError((errorJson) =>
Future.error(BleError.fromJson(jsonDecode(errorJson.details))));
}
}
}
2 changes: 0 additions & 2 deletions lib/internal/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,3 @@ abstract class NativeConnectionState {
static const String disconnecting = "disconnecting";
static const String disconnected = "disconnected";
}


19 changes: 10 additions & 9 deletions lib/internal/internal_ble_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class InternalBleManager
Future<BluetoothState> bluetoothState() => _bleLib.state();

@override
Stream<BluetoothState> observeBluetoothState({bool emitCurrentValue = true}) =>
Stream<BluetoothState> observeBluetoothState(
{bool emitCurrentValue = true}) =>
_bleLib.observeBluetoothState(emitCurrentValue);

@override
Expand Down Expand Up @@ -73,12 +74,11 @@ class InternalBleManager

@override
Stream<PeripheralConnectionState> observePeripheralConnectionState(
String peripheralIdentifier,
bool emitCurrentValue,
bool completeOnDisconnect
) {

var streamTransformer = StreamTransformer<PeripheralConnectionState, PeripheralConnectionState>.fromHandlers(
String peripheralIdentifier,
bool emitCurrentValue,
bool completeOnDisconnect) {
var streamTransformer = StreamTransformer<PeripheralConnectionState,
PeripheralConnectionState>.fromHandlers(
handleData: (PeripheralConnectionState data, EventSink sink) {
sink.add(data);
if (data == PeripheralConnectionState.disconnected) {
Expand All @@ -90,7 +90,7 @@ class InternalBleManager
},
handleDone: (EventSink sink) => sink.close());

var stream = _bleLib.observePeripheralConnectionState(
var stream = _bleLib.observePeripheralConnectionState(
peripheralIdentifier, emitCurrentValue);
if (completeOnDisconnect) {
return stream.transform(streamTransformer);
Expand Down Expand Up @@ -156,7 +156,8 @@ class InternalBleManager
}

@override
Future<List<Peripheral>> knownPeripherals(List<String> peripheralIdentifiers) {
Future<List<Peripheral>> knownPeripherals(
List<String> peripheralIdentifiers) {
return _bleLib.knownDevices(peripheralIdentifiers ?? []);
}

Expand Down
4 changes: 3 additions & 1 deletion lib/internal/managers_for_classes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ abstract class ManagerForPeripheral {
String peripheralIdentifier);

Stream<PeripheralConnectionState> observePeripheralConnectionState(
String peripheralIdentifier, bool emitCurrentValue, bool completeOnDisconnect);
String peripheralIdentifier,
bool emitCurrentValue,
bool completeOnDisconnect);

Future<void> discoverAllServicesAndCharacteristics(
Peripheral peripheral, String transactionId);
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/util/transformers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ class CancelOnErrorStreamTransformer<T> extends StreamTransformerBase<T, T> {
sink.close();
},
));
}
}
13 changes: 8 additions & 5 deletions lib/scan_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ class AdvertisementData {
List<String> solicitedServiceUUIDs;

AdvertisementData._fromJson(Map<String, dynamic> json)
: manufacturerData = _decodeBase64OrNull(_ScanResultMetadata.manufacturerData),
serviceData = _getServiceDataOrNull(json[_ScanResultMetadata.serviceData]),
serviceUUIDs = _mapToListOfStringsOrNull(json[_ScanResultMetadata.serviceUuids]),
: manufacturerData =
_decodeBase64OrNull(_ScanResultMetadata.manufacturerData),
serviceData =
_getServiceDataOrNull(json[_ScanResultMetadata.serviceData]),
serviceUUIDs =
_mapToListOfStringsOrNull(json[_ScanResultMetadata.serviceUuids]),
localName = json[_ScanResultMetadata.localName],
txPowerLevel = json[_ScanResultMetadata.txPowerLevel],
solicitedServiceUUIDs =
_mapToListOfStringsOrNull(json[_ScanResultMetadata.solicitedServiceUuids]);
solicitedServiceUUIDs = _mapToListOfStringsOrNull(
json[_ScanResultMetadata.solicitedServiceUuids]);

static Map<String, Int8List> _getServiceDataOrNull(
Map<String, dynamic> serviceData) {
Expand Down

0 comments on commit 0ef7df7

Please sign in to comment.