Skip to content

Commit

Permalink
Fixed lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen1602 committed Dec 7, 2023
1 parent a07b3fb commit 643f11b
Show file tree
Hide file tree
Showing 65 changed files with 157 additions and 161 deletions.
3 changes: 1 addition & 2 deletions lib/lighthouse_provider/lighthouse_provider_start.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:bluez_back_end/bluez_back_end.dart';
import 'package:fake_back_end/fake_back_end.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_reactive_ble_back_end/flutter_reactive_ble_end.dart';
import 'package:flutter_web_bluetooth_back_end/flutter_web_bluetooth_back_end.dart';
Expand Down Expand Up @@ -44,7 +43,7 @@ class LighthouseProviderStart {
// you'll also need to
// import 'package:lighthouse_pm/lighthouse_back_ends/fake/fake_back_end.dart';

LighthouseProvider.instance.addBackEnd(FakeBLEBackEnd.instance);
// LighthouseProvider.instance.addBackEnd(FakeBLEBackEnd.instance);
return true;
}());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ class LighthouseMetadataState extends State<LighthouseMetadataPage> {
}

class _MetadataInkWell extends StatelessWidget {
const _MetadataInkWell(
{required this.name, this.value, this.onTap});
const _MetadataInkWell({required this.name, this.value, this.onTap});

final String name;
final String? value;
Expand Down
3 changes: 1 addition & 2 deletions lib/lighthouse_provider/widgets/lighthouse_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ class LighthouseWidgetState extends State<LighthouseWidget> {
/// Display the state of the device together with the state as a number in hex.
class _LHItemPowerStateWidget extends StatelessWidget {
const _LHItemPowerStateWidget(
{required this.powerStateByte,
required this.toPowerState});
{required this.powerStateByte, required this.toPowerState});

final int? powerStateByte;
final _ToPowerState toPowerState;
Expand Down
3 changes: 2 additions & 1 deletion lib/pages/main_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class _ScanDevicesPage extends State<ScanDevicesPage>
Widget build(final BuildContext context) {
final selecting = selected.isNotEmpty || selectedGroup != null;
return buildScanPopScope(
beforeWillPop: () async {
beforeWillPop: () {
if (selecting) {
setState(() {
clearSelected();
Expand Down Expand Up @@ -770,6 +770,7 @@ class _ScanDevicesPage extends State<ScanDevicesPage>
@override
void didChangeAppLifecycleState(final AppLifecycleState state) {
switch (state) {
case AppLifecycleState.hidden:
case AppLifecycleState.paused:
setState(() {
updates = 0;
Expand Down
1 change: 1 addition & 0 deletions lib/pages/shortcut/mac_shortcut_handle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class ShortcutHandleMacState extends State<ShortcutHandlerWidget>
@override
void didChangeAppLifecycleState(final AppLifecycleState state) {
switch (state) {
case AppLifecycleState.hidden:
case AppLifecycleState.paused:
cleanUp();
break;
Expand Down
4 changes: 1 addition & 3 deletions lib/pages/shortcut/states/get_device_state_stream.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ class GetDeviceStateStream extends WaterfallStreamWidget<LighthousePowerState>
final int settingsIndex;

GetDeviceStateStream(this.settingsIndex,
{super.key,
required super.upStream,
super.downStreamBuilders});
{super.key, required super.upStream, super.downStreamBuilders});

Stream<WithTimeout<LighthousePowerState>> getDeviceState(
final StatefulLighthouseDevice device, final Duration timeout) {
Expand Down
4 changes: 1 addition & 3 deletions lib/pages/shortcut/states/get_device_stream.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ class GetDeviceStream extends WaterfallStreamWidget<LighthouseDevice>
final int settingsIndex;

GetDeviceStream(this.deviceId, this.settingsIndex,
{required super.upStream,
required super.downStreamBuilders,
super.key});
{required super.upStream, required super.downStreamBuilders, super.key});

Stream<WithTimeout<LighthouseDevice?>> listenForDevice(
final Duration timeout) {
Expand Down
4 changes: 1 addition & 3 deletions lib/pages/shortcut/states/permission_stream.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import 'package:permission_handler/permission_handler.dart';
class PermissionsStream extends WaterfallStreamWidget<PermissionStatus>
with ScanningMixin, CloseCurrentRouteMixin {
PermissionsStream(
{super.key,
required super.upStream,
super.downStreamBuilders});
{super.key, required super.upStream, super.downStreamBuilders});

@override
Widget build(final BuildContext context) {
Expand Down
4 changes: 1 addition & 3 deletions lib/pages/shortcut/states/settings_stream.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import 'package:lighthouse_pm/widgets/waterfall_widget.dart';
class SettingsStream extends WaterfallStreamWidget<MainPageSettings>
with WithBlocStateless {
SettingsStream(
{super.key,
required super.upStream,
super.downStreamBuilders});
{super.key, required super.upStream, super.downStreamBuilders});

@override
Widget build(final BuildContext context) {
Expand Down
4 changes: 1 addition & 3 deletions lib/pages/shortcut_handler_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ class ShortcutHandlerPage extends BasePage {
final Object? handle;

const ShortcutHandlerPage(this.handle, {super.key})
: super(
shortcutHandleArgument: handle as ShortcutHandle?,
replace: true);
: super(shortcutHandleArgument: handle as ShortcutHandle?, replace: true);

@override
Widget buildPage(final BuildContext context) {
Expand Down
3 changes: 1 addition & 2 deletions lib/pages/simple_base_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import 'base_page.dart';
class SimpleBasePage extends BasePage {
final Widget _body;

const SimpleBasePage(this._body,
{super.key, super.shortcutHandleArgument});
const SimpleBasePage(this._body, {super.key, super.shortcutHandleArgument});

@override
Widget buildPage(final BuildContext context) {
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/content_container_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class ContentScrollbar extends StatelessWidget {
final ScrollController? controller,
required this.scrollbarChildBuilder,
this.maxSize = ContentContainerWidget.defaultMaxSize,
}) : controller = controller ?? ScrollController();
}) : controller = controller ?? ScrollController();

final ScrollbarChildBuilder scrollbarChildBuilder;

Expand Down
3 changes: 1 addition & 2 deletions lib/widgets/dao_data_create_alert_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ abstract class DaoDataCreateAlertDecorator<T> {
///
class DaoDataCreateAlertStringDecorator
extends DaoDataCreateAlertDecorator<String> {
DaoDataCreateAlertStringDecorator(
super.name, super.originalValue,
DaoDataCreateAlertStringDecorator(super.name, super.originalValue,
{this.validator});

final FormFieldValidator<String>? validator;
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/markdown/src/icon_builder.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of lighthouse_markdown;
part of '../markdown.dart';

///
/// Convert an [md.Element] to the actual [Widget] for rendering. Use [IconSyntax]
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/markdown/src/icon_syntax.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of lighthouse_markdown;
part of '../markdown.dart';

///
/// Convert an <icon>{the icon}</icon> tag into an element that can be used in
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/markdown/src/markdown_tap_link.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of lighthouse_markdown;
part of '../markdown.dart';

markdownOpenLinkOnTap(
final String text, final String? href, final String title) {
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/markdown/src/super_script_syntax.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of lighthouse_markdown;
part of '../markdown.dart';

///
/// Convert the markdown content inside the `<sup>` tag into actual super
Expand Down
3 changes: 2 additions & 1 deletion lib/widgets/material/selectable_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,11 @@ Text _createTextWithStyle(final Text old, final Color selectedAppBarTextColor,
locale: old.locale,
softWrap: old.softWrap,
overflow: old.overflow,
textScaleFactor: old.textScaleFactor,
textScaler: old.textScaler,
maxLines: old.maxLines,
semanticsLabel: old.semanticsLabel,
textWidthBasis: old.textWidthBasis,
textHeightBehavior: old.textHeightBehavior,
selectionColor: old.selectionColor,
);
}
37 changes: 37 additions & 0 deletions lib/widgets/multiple_callback_pop_scope.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:flutter/widgets.dart';

class MultipleCallbackPopScope extends StatefulWidget {
const MultipleCallbackPopScope({
super.key,
required this.child,
this.canPop = const [],
});

final Widget child;
final List<CanPop> canPop;

@override
State<StatefulWidget> createState() {
return _MultipleCallbackPopScopeState();
}
}

class _MultipleCallbackPopScopeState extends State<MultipleCallbackPopScope> {
@override
Widget build(final BuildContext context) {
return PopScope(
canPop: false,
onPopInvoked: (final bool didPop) {
for (final canPop in widget.canPop) {
if (!canPop()) {
return;
}
}
Navigator.pop(context);
},
child: widget.child,
);
}
}

typedef CanPop = bool Function();
36 changes: 16 additions & 20 deletions lib/widgets/scanning_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import 'package:lighthouse_pm/permissions_helper/ble_permissions_helper.dart';
import 'package:lighthouse_provider/lighthouse_provider.dart';
import 'package:permission_handler/permission_handler.dart';

import 'multiple_callback_pop_scope.dart';

abstract class ScanningMixin {
Future<bool> _onWillPop() async {
bool _onWillPop() {
return true;
}

Expand Down Expand Up @@ -38,25 +40,19 @@ abstract class ScanningMixin {

Widget buildScanPopScope(
{required final Widget child,
final WillPopCallback? beforeWillPop,
final WillPopCallback? afterWillPop}) {
return WillPopScope(
onWillPop: () async {
if (beforeWillPop != null) {
if (!await beforeWillPop()) {
return false;
}
}
if (!await _onWillPop()) {
return false;
}
if (afterWillPop != null) {
if (!await afterWillPop()) {
return false;
}
}
return true;
},
final CanPop? beforeWillPop,
final CanPop? afterWillPop}) {
final canPopList = <CanPop>[];
if (beforeWillPop != null) {
canPopList.add(beforeWillPop);
}
canPopList.add(_onWillPop);
if (afterWillPop != null) {
canPopList.add(afterWillPop);
}

return MultipleCallbackPopScope(
canPop: canPopList,
child: child,
);
}
Expand Down
4 changes: 1 addition & 3 deletions lib/widgets/waterfall_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ abstract class WaterfallStreamWidget<T> extends StatelessWidget {
final List<DownStreamBuilder> downStreamBuilders;

const WaterfallStreamWidget(
{super.key,
required this.upStream,
this.downStreamBuilders = const []});
{super.key, required this.upStream, this.downStreamBuilders = const []});

WaterfallStreamWidget getNextStreamDown(
final BuildContext context, final T? upstreamData) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of lighthouse_back_end;
part of '../../lighthouse_back_end.dart';

///
/// A back end that will use [BLEDeviceProvider]s to provide [BLEDevice]s
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of lighthouse_back_end;
part of '../../lighthouse_back_end.dart';

///
/// A back end that requires the user to pair a device before it's able to be
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of lighthouse_back_end;
part of '../../lighthouse_back_end.dart';

/// An abstract class for bluetooth characteristic.
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of lighthouse_back_end;
part of '../../lighthouse_back_end.dart';

/// An abstract class for bluetooth devices.
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of lighthouse_back_end;
part of '../../lighthouse_back_end.dart';

/// An abstract bluetooth service.
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of lighthouse_back_end;
part of '../../lighthouse_back_end.dart';

///
/// A device for all other devices.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of lighthouse_back_end;
part of '../../lighthouse_back_end.dart';

/// What a back end device should at least have for the providers to work with it.
abstract class LowLevelDevice {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of lighthouse_back_end;
part of '../../lighthouse_back_end.dart';

///
/// An abstract device provider specifically made for Bluetooth low energy.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of lighthouse_back_end;
part of '../../lighthouse_back_end.dart';

///
/// Extension functions for [ByteData]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of lighthouse_back_end;
part of '../../lighthouse_back_end.dart';

///
/// An abstract super class of what all device provider should be able to do.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of bluez_back_end;
part of '../bluez_back_end_io.dart';

class BlueZBluetoothCharacteristic extends LHBluetoothCharacteristic {
BlueZBluetoothCharacteristic(this.characteristic);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of bluez_back_end;
part of '../bluez_back_end_io.dart';

class BlueZBluetoothDevice extends LHBluetoothDevice {
BlueZBluetoothDevice(this.device) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of bluez_back_end;
part of '../bluez_back_end_io.dart';

class BlueZBluetoothService extends LHBluetoothService {
BlueZBluetoothService(this.service);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of fake_back_end;
part of '../../fake_back_end.dart';

class FakeBluetoothDevice extends LHBluetoothDevice {
final LHDeviceIdentifier deviceIdentifier;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of fake_back_end;
part of '../../fake_back_end.dart';

abstract class FakeDeviceIdentifier {
static LHDeviceIdentifier generateDeviceIdentifier(final int seed) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
part of flutter_reactive_ble_back_end;
part of '../flutter_reactive_ble_io.dart';

class FlutterReactiveBleCharacteristic extends LHBluetoothCharacteristic {
FlutterReactiveBleCharacteristic(
final String deviceId,
final DiscoveredCharacteristic characteristic,
final Characteristic characteristic,
) : _qualifiedCharacteristic = QualifiedCharacteristic(
characteristicId: characteristic.characteristicId,
serviceId: characteristic.serviceId,
characteristicId: characteristic.id,
serviceId: characteristic.service.id,
deviceId: deviceId),
uuid = LighthouseGuid.fromString(
characteristic.characteristicId.toString());
uuid = LighthouseGuid.fromString(characteristic.id.toString());

final QualifiedCharacteristic _qualifiedCharacteristic;
final _flutterReactiveBle = FlutterReactiveBle();
Expand Down
Loading

0 comments on commit 643f11b

Please sign in to comment.