From a6a824dcf5bd6427aae7e0c72cb73d62d35b2f26 Mon Sep 17 00:00:00 2001 From: Dariusz Seweryn Date: Fri, 17 Jul 2020 16:41:05 +0200 Subject: [PATCH] Formatted all files according to `dartfmt` --- .../device_details/device_detail_view.dart | 23 +++++++++------- .../device_details/view/auto_test_view.dart | 6 +---- .../lib/device_details/view/button_view.dart | 6 ++--- .../view/logs_container_view.dart | 2 -- .../device_details/view/manual_test_view.dart | 7 ++--- example/lib/main.dart | 26 +++++++++---------- example/lib/repository/device_repository.dart | 10 +++---- example/lib/test_scenarios/base.dart | 2 +- .../bluetooth_state_toggle_scenario.dart | 3 ++- .../sensor_tag_test_scenario.dart | 26 ++++++++++--------- .../lib/test_scenarios/test_scenarios.dart | 2 +- example/lib/util/pair.dart | 2 +- example/test/widget_test.dart | 4 +-- lib/descriptor.dart | 20 +++++++------- test/ble_manager_test.dart | 3 +-- test/mock/mocks.dart | 3 ++- test/scan_result.dart | 1 - test/service_test.dart | 12 +++++---- .../util/transcation_id_generator_test.dart | 2 +- 19 files changed, 79 insertions(+), 81 deletions(-) diff --git a/example/lib/device_details/device_detail_view.dart b/example/lib/device_details/device_detail_view.dart index 6d90a9fa..dc8948a7 100644 --- a/example/lib/device_details/device_detail_view.dart +++ b/example/lib/device_details/device_detail_view.dart @@ -10,7 +10,6 @@ import 'package:flutter_ble_lib_example/device_details/view/manual_test_view.dar class DeviceDetailsView extends StatefulWidget { @override State createState() => DeviceDetailsViewState(); - } class DeviceDetailsViewState extends State { @@ -37,12 +36,12 @@ class DeviceDetailsViewState extends State { _deviceDetailsBloc.init(); _appStateSubscription = _deviceDetailsBloc.disconnectedDevice.listen((bleDevice) async { - Fimber.d("navigate to details"); - _onPause(); - Navigator.pop(context); - _shouldRunOnResume = true; - Fimber.d("back from details"); - }); + Fimber.d("navigate to details"); + _onPause(); + Navigator.pop(context); + _shouldRunOnResume = true; + Fimber.d("back from details"); + }); } void _onPause() { @@ -74,8 +73,14 @@ class DeviceDetailsViewState extends State { title: Text('Device Details'), bottom: TabBar( tabs: [ - Tab(icon: Icon(Icons.autorenew), text: "Automatic",), - Tab(icon: Icon(Icons.settings), text: "Manual",), + Tab( + icon: Icon(Icons.autorenew), + text: "Automatic", + ), + Tab( + icon: Icon(Icons.settings), + text: "Manual", + ), ], ), ), diff --git a/example/lib/device_details/view/auto_test_view.dart b/example/lib/device_details/view/auto_test_view.dart index a8f40914..5717a11d 100644 --- a/example/lib/device_details/view/auto_test_view.dart +++ b/example/lib/device_details/view/auto_test_view.dart @@ -1,12 +1,9 @@ - import 'package:flutter/material.dart'; import 'package:flutter_ble_lib_example/device_details/device_details_bloc.dart'; import 'package:flutter_ble_lib_example/device_details/view/button_view.dart'; import 'package:flutter_ble_lib_example/device_details/view/logs_container_view.dart'; - class AutoTestView extends StatelessWidget { - final DeviceDetailsBloc _deviceDetailsBloc; AutoTestView(this._deviceDetailsBloc); @@ -41,5 +38,4 @@ class AutoTestView extends StatelessWidget { void _startAutoTest() { _deviceDetailsBloc.startAutoTest(); } - -} \ No newline at end of file +} diff --git a/example/lib/device_details/view/button_view.dart b/example/lib/device_details/view/button_view.dart index d795fa3f..f9789f61 100644 --- a/example/lib/device_details/view/button_view.dart +++ b/example/lib/device_details/view/button_view.dart @@ -1,12 +1,10 @@ - import 'package:flutter/material.dart'; class ButtonView extends StatelessWidget { - final String _text; final Function action; - ButtonView(this._text, { this.action }); + ButtonView(this._text, {this.action}); @override Widget build(BuildContext context) { @@ -22,4 +20,4 @@ class ButtonView extends StatelessWidget { ), ); } -} \ No newline at end of file +} diff --git a/example/lib/device_details/view/logs_container_view.dart b/example/lib/device_details/view/logs_container_view.dart index dcd89dc4..37398d9f 100644 --- a/example/lib/device_details/view/logs_container_view.dart +++ b/example/lib/device_details/view/logs_container_view.dart @@ -1,10 +1,8 @@ - import 'package:flutter/material.dart'; import 'package:flutter_ble_lib_example/device_details/device_details_bloc.dart'; import 'package:rxdart/rxdart.dart'; class LogsContainerView extends StatelessWidget { - final Observable> _logs; LogsContainerView(this._logs); diff --git a/example/lib/device_details/view/manual_test_view.dart b/example/lib/device_details/view/manual_test_view.dart index f3966180..a01120ce 100644 --- a/example/lib/device_details/view/manual_test_view.dart +++ b/example/lib/device_details/view/manual_test_view.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:flutter_ble_lib_example/device_details/device_details_bloc.dart'; import 'package:flutter_ble_lib_example/device_details/view/button_view.dart'; @@ -173,8 +172,10 @@ class ManualTestView extends StatelessWidget { padding: const EdgeInsets.symmetric(vertical: 2.0), child: Row( children: [ - ButtonView("Monitor temp", action: _monitorCharacteristicForPeripheral), - ButtonView("Turn on temp", action: _writeCharacteristicForPeripheral), + ButtonView("Monitor temp", + action: _monitorCharacteristicForPeripheral), + ButtonView("Turn on temp", + action: _writeCharacteristicForPeripheral), ButtonView("Read temp", action: _readCharacteristicForPeripheral), ], ), diff --git a/example/lib/main.dart b/example/lib/main.dart index f5015a3b..25005b03 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -14,21 +14,21 @@ void main() { final RouteObserver routeObserver = RouteObserver(); class MyApp extends StatelessWidget { - @override Widget build(BuildContext context) { return MaterialApp( - title: 'FlutterBleLib example', - theme: new ThemeData( - primaryColor: new Color(0xFF0A3D91), - accentColor: new Color(0xFFCC0000), - ), - initialRoute: "/", - routes: { - "/": (context) => DevicesBlocProvider(child: DevicesListScreen()), - "/details": (context) => DeviceDetailsBlocProvider(child: DeviceDetailsView()), - }, - navigatorObservers: [routeObserver], - ); + title: 'FlutterBleLib example', + theme: new ThemeData( + primaryColor: new Color(0xFF0A3D91), + accentColor: new Color(0xFFCC0000), + ), + initialRoute: "/", + routes: { + "/": (context) => DevicesBlocProvider(child: DevicesListScreen()), + "/details": (context) => + DeviceDetailsBlocProvider(child: DeviceDetailsView()), + }, + navigatorObservers: [routeObserver], + ); } } diff --git a/example/lib/repository/device_repository.dart b/example/lib/repository/device_repository.dart index 8627fa3f..b9fa1978 100644 --- a/example/lib/repository/device_repository.dart +++ b/example/lib/repository/device_repository.dart @@ -1,16 +1,14 @@ - import 'package:flutter_ble_lib_example/model/ble_device.dart'; import 'package:rxdart/rxdart.dart'; class MissingPickedDeviceException implements Exception {} class DeviceRepository { - static BleDevice _bleDevice; BehaviorSubject _deviceController; - static final DeviceRepository _deviceRepository = DeviceRepository - ._internal(); + static final DeviceRepository _deviceRepository = + DeviceRepository._internal(); factory DeviceRepository() { return _deviceRepository; @@ -25,8 +23,8 @@ class DeviceRepository { _deviceController.add(_bleDevice); } - ValueObservable get pickedDevice => _deviceController.stream.shareValueSeeded(_bleDevice); + ValueObservable get pickedDevice => + _deviceController.stream.shareValueSeeded(_bleDevice); bool get hasPickedDevice => _bleDevice != null; - } diff --git a/example/lib/test_scenarios/base.dart b/example/lib/test_scenarios/base.dart index 2aa90e04..fd240fd7 100644 --- a/example/lib/test_scenarios/base.dart +++ b/example/lib/test_scenarios/base.dart @@ -4,4 +4,4 @@ typedef Logger = Function(String); abstract class TestScenario { Future runTestScenario(Logger log, Logger errorLogger); -} \ No newline at end of file +} diff --git a/example/lib/test_scenarios/bluetooth_state_toggle_scenario.dart b/example/lib/test_scenarios/bluetooth_state_toggle_scenario.dart index 2eb45763..043582c8 100644 --- a/example/lib/test_scenarios/bluetooth_state_toggle_scenario.dart +++ b/example/lib/test_scenarios/bluetooth_state_toggle_scenario.dart @@ -46,7 +46,8 @@ class BluetoothStateTestScenario implements TestScenario { void _observeRadioState(BleManager bleManager, Logger log) async { await _radioStateSubscription?.cancel(); - _radioStateSubscription = bleManager.observeBluetoothState().listen((newState) { + _radioStateSubscription = + bleManager.observeBluetoothState().listen((newState) { log("New radio state: $newState"); }, onError: (error) { log("Error while observing radio state. Error: $error"); diff --git a/example/lib/test_scenarios/sensor_tag_test_scenario.dart b/example/lib/test_scenarios/sensor_tag_test_scenario.dart index c1151c28..9ce95c4b 100644 --- a/example/lib/test_scenarios/sensor_tag_test_scenario.dart +++ b/example/lib/test_scenarios/sensor_tag_test_scenario.dart @@ -3,32 +3,34 @@ part of test_scenarios; class SensorTagTestScenario { PeripheralTestOperations _peripheralTestOperations; - SensorTagTestScenario(BleManager bleManager, - Peripheral peripheral, - Logger log, - Logger logError) { - _peripheralTestOperations = PeripheralTestOperations(bleManager, peripheral, log, logError); + SensorTagTestScenario(BleManager bleManager, Peripheral peripheral, + Logger log, Logger logError) { + _peripheralTestOperations = + PeripheralTestOperations(bleManager, peripheral, log, logError); } Future runTestScenario() async { - _peripheralTestOperations.connect() + _peripheralTestOperations + .connect() .then((_) => _peripheralTestOperations.cancelTransaction()) .then((_) => _peripheralTestOperations.discovery()) .then((_) => _peripheralTestOperations.testRequestingMtu()) .then((_) => _peripheralTestOperations.testReadingRssi()) - .then((_) => _peripheralTestOperations.readWriteMonitorCharacteristicForPeripheral()) - .then((_) => _peripheralTestOperations.readWriteMonitorCharacteristicForService()) + .then((_) => _peripheralTestOperations + .readWriteMonitorCharacteristicForPeripheral()) + .then((_) => _peripheralTestOperations + .readWriteMonitorCharacteristicForService()) .then((_) => _peripheralTestOperations.readWriteMonitorCharacteristic()) .then((_) => Future.delayed(Duration(milliseconds: 100))) - .then((_) => _peripheralTestOperations.readWriteDescriptorForPeripheral()) + .then( + (_) => _peripheralTestOperations.readWriteDescriptorForPeripheral()) .then((_) => _peripheralTestOperations.readWriteDescriptorForService()) - .then((_) => _peripheralTestOperations.readWriteDescriptorForCharacteristic()) + .then((_) => + _peripheralTestOperations.readWriteDescriptorForCharacteristic()) .then((_) => _peripheralTestOperations.readWriteDescriptor()) .then((_) => _peripheralTestOperations.fetchConnectedDevice()) .then((_) => _peripheralTestOperations.fetchKnownDevice()) .then((_) => _peripheralTestOperations.disconnect()) .catchError((error) => _peripheralTestOperations.logError(error)); } - - } diff --git a/example/lib/test_scenarios/test_scenarios.dart b/example/lib/test_scenarios/test_scenarios.dart index 076b4bfe..e79ba77b 100644 --- a/example/lib/test_scenarios/test_scenarios.dart +++ b/example/lib/test_scenarios/test_scenarios.dart @@ -12,4 +12,4 @@ part 'base.dart'; part 'sensor_tag_test_with_scan_and_connection_scenario.dart'; part 'bluetooth_state_toggle_scenario.dart'; part 'sensor_tag_test_scenario.dart'; -part 'peripheral_test_operations.dart'; \ No newline at end of file +part 'peripheral_test_operations.dart'; diff --git a/example/lib/util/pair.dart b/example/lib/util/pair.dart index 5ee17510..4782b7c2 100644 --- a/example/lib/util/pair.dart +++ b/example/lib/util/pair.dart @@ -6,4 +6,4 @@ class Pair { @override String toString() => 'Pair[$first, $second]'; -} \ No newline at end of file +} diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index 4f97d538..def6a68d 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -18,8 +18,8 @@ void main() { // Verify that platform version is retrieved. expect( find.byWidgetPredicate( - (Widget widget) => widget is Text && - widget.data.startsWith('Running on:'), + (Widget widget) => + widget is Text && widget.data.startsWith('Running on:'), ), findsOneWidget, ); diff --git a/lib/descriptor.dart b/lib/descriptor.dart index 5e2e265a..6e43cee5 100644 --- a/lib/descriptor.dart +++ b/lib/descriptor.dart @@ -1,9 +1,9 @@ part of flutter_ble_lib; abstract class _DescriptorMetadata { - static const String uuid = "descriptorUuid"; - static const String id = "descriptorId"; - static const String value = "value"; + static const String uuid = 'descriptorUuid'; + static const String id = 'descriptorId'; + static const String value = 'value'; } class Descriptor extends InternalDescriptor { @@ -37,17 +37,15 @@ class Descriptor extends InternalDescriptor { @override bool operator ==(Object other) => identical(this, other) || - other is Descriptor && - runtimeType == other.runtimeType && - _manager == other._manager && - characteristic == other.characteristic && - uuid == other.uuid; + other is Descriptor && + runtimeType == other.runtimeType && + _manager == other._manager && + characteristic == other.characteristic && + uuid == other.uuid; @override int get hashCode => - _manager.hashCode ^ - characteristic.hashCode ^ - uuid.hashCode; + _manager.hashCode ^ characteristic.hashCode ^ uuid.hashCode; } class DescriptorWithValue extends Descriptor with WithValue { diff --git a/test/ble_manager_test.dart b/test/ble_manager_test.dart index e4470b31..f4c2c86a 100644 --- a/test/ble_manager_test.dart +++ b/test/ble_manager_test.dart @@ -1,4 +1,3 @@ - import 'package:flutter_ble_lib/flutter_ble_lib.dart'; import 'package:test/test.dart'; @@ -13,4 +12,4 @@ void main() { //then expect(secondInstanceOfBleManager, same(firstInstanceOfBlemanager)); }); -} \ No newline at end of file +} diff --git a/test/mock/mocks.dart b/test/mock/mocks.dart index 9d342fad..0bfb4388 100644 --- a/test/mock/mocks.dart +++ b/test/mock/mocks.dart @@ -4,7 +4,8 @@ import 'package:mockito/mockito.dart'; class ManagerForServiceMock extends Mock implements ManagerForService {} -class ManagerForCharacteristicMock extends Mock implements ManagerForCharacteristic {} +class ManagerForCharacteristicMock extends Mock + implements ManagerForCharacteristic {} class ManagerForDescriptorMock extends Mock implements ManagerForDescriptor {} diff --git a/test/scan_result.dart b/test/scan_result.dart index 75a41cc2..12365e0c 100644 --- a/test/scan_result.dart +++ b/test/scan_result.dart @@ -66,7 +66,6 @@ String _createJsonScanResult({ int txPowerLevel, List solicitedServiceUuids, }) { - String serializedManufacturerData; if (manufacturerData != null) { serializedManufacturerData = "\"${base64Encode(manufacturerData)}\""; diff --git a/test/service_test.dart b/test/service_test.dart index 10ead0e7..1c70e155 100644 --- a/test/service_test.dart +++ b/test/service_test.dart @@ -63,14 +63,16 @@ void main() { ])); }); - test("descriptorsForCharacteristic returns characteristics provided by manager", () async { + test( + "descriptorsForCharacteristic returns characteristics provided by manager", + () async { //given when(managerForService.descriptorsForService(service, "123")) .thenAnswer((_) => Future.value([ - createDescriptor(0), - createDescriptor(1), - createDescriptor(2), - ])); + createDescriptor(0), + createDescriptor(1), + createDescriptor(2), + ])); //when var descriptors = await service.descriptorsForCharacteristic("123"); diff --git a/test/src/util/transcation_id_generator_test.dart b/test/src/util/transcation_id_generator_test.dart index efa66cd9..6d93a5af 100644 --- a/test/src/util/transcation_id_generator_test.dart +++ b/test/src/util/transcation_id_generator_test.dart @@ -14,4 +14,4 @@ void main() { generatedIds.add(generatedId); } }); -} \ No newline at end of file +}