Skip to content

Commit

Permalink
Formatted all files according to dartfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
dariuszseweryn committed Jul 17, 2020
1 parent 8d97bf5 commit a6a824d
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 81 deletions.
23 changes: 14 additions & 9 deletions example/lib/device_details/device_detail_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import 'package:flutter_ble_lib_example/device_details/view/manual_test_view.dar
class DeviceDetailsView extends StatefulWidget {
@override
State<DeviceDetailsView> createState() => DeviceDetailsViewState();

}

class DeviceDetailsViewState extends State<DeviceDetailsView> {
Expand All @@ -37,12 +36,12 @@ class DeviceDetailsViewState extends State<DeviceDetailsView> {
_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() {
Expand Down Expand Up @@ -74,8 +73,14 @@ class DeviceDetailsViewState extends State<DeviceDetailsView> {
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",
),
],
),
),
Expand Down
6 changes: 1 addition & 5 deletions example/lib/device_details/view/auto_test_view.dart
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -41,5 +38,4 @@ class AutoTestView extends StatelessWidget {
void _startAutoTest() {
_deviceDetailsBloc.startAutoTest();
}

}
}
6 changes: 2 additions & 4 deletions example/lib/device_details/view/button_view.dart
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -22,4 +20,4 @@ class ButtonView extends StatelessWidget {
),
);
}
}
}
2 changes: 0 additions & 2 deletions example/lib/device_details/view/logs_container_view.dart
Original file line number Diff line number Diff line change
@@ -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<List<DebugLog>> _logs;

LogsContainerView(this._logs);
Expand Down
7 changes: 4 additions & 3 deletions example/lib/device_details/view/manual_test_view.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -173,8 +172,10 @@ class ManualTestView extends StatelessWidget {
padding: const EdgeInsets.symmetric(vertical: 2.0),
child: Row(
children: <Widget>[
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),
],
),
Expand Down
26 changes: 13 additions & 13 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ void main() {
final RouteObserver<PageRoute> routeObserver = RouteObserver<PageRoute>();

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: <String, WidgetBuilder>{
"/": (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: <String, WidgetBuilder>{
"/": (context) => DevicesBlocProvider(child: DevicesListScreen()),
"/details": (context) =>
DeviceDetailsBlocProvider(child: DeviceDetailsView()),
},
navigatorObservers: [routeObserver],
);
}
}
10 changes: 4 additions & 6 deletions example/lib/repository/device_repository.dart
Original file line number Diff line number Diff line change
@@ -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<BleDevice> _deviceController;

static final DeviceRepository _deviceRepository = DeviceRepository
._internal();
static final DeviceRepository _deviceRepository =
DeviceRepository._internal();

factory DeviceRepository() {
return _deviceRepository;
Expand All @@ -25,8 +23,8 @@ class DeviceRepository {
_deviceController.add(_bleDevice);
}

ValueObservable<BleDevice> get pickedDevice => _deviceController.stream.shareValueSeeded(_bleDevice);
ValueObservable<BleDevice> get pickedDevice =>
_deviceController.stream.shareValueSeeded(_bleDevice);

bool get hasPickedDevice => _bleDevice != null;

}
2 changes: 1 addition & 1 deletion example/lib/test_scenarios/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ typedef Logger = Function(String);

abstract class TestScenario {
Future<void> runTestScenario(Logger log, Logger errorLogger);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
26 changes: 14 additions & 12 deletions example/lib/test_scenarios/sensor_tag_test_scenario.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> 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));
}


}
2 changes: 1 addition & 1 deletion example/lib/test_scenarios/test_scenarios.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
part 'peripheral_test_operations.dart';
2 changes: 1 addition & 1 deletion example/lib/util/pair.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class Pair<T, S> {

@override
String toString() => 'Pair[$first, $second]';
}
}
4 changes: 2 additions & 2 deletions example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
20 changes: 9 additions & 11 deletions lib/descriptor.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions test/ble_manager_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import 'package:flutter_ble_lib/flutter_ble_lib.dart';
import 'package:test/test.dart';

Expand All @@ -13,4 +12,4 @@ void main() {
//then
expect(secondInstanceOfBleManager, same(firstInstanceOfBlemanager));
});
}
}
3 changes: 2 additions & 1 deletion test/mock/mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

Expand Down
1 change: 0 additions & 1 deletion test/scan_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ String _createJsonScanResult({
int txPowerLevel,
List<String> solicitedServiceUuids,
}) {

String serializedManufacturerData;
if (manufacturerData != null) {
serializedManufacturerData = "\"${base64Encode(manufacturerData)}\"";
Expand Down
12 changes: 7 additions & 5 deletions test/service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion test/src/util/transcation_id_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ void main() {
generatedIds.add(generatedId);
}
});
}
}

0 comments on commit a6a824d

Please sign in to comment.