From 9ef55be2dfbf7129d06ef05c018ce05239216a34 Mon Sep 17 00:00:00 2001 From: Vadim Date: Thu, 11 May 2023 14:58:57 +0200 Subject: [PATCH] dart fixes --- analysis_options.yaml | 6 +++++- lib/application.dart | 4 ++-- lib/data/models/exposure_pair.dart | 2 +- lib/data/models/metering_screen_layout_config.dart | 2 +- lib/data/shared_prefs_service.dart | 4 +++- lib/interactors/metering_interactor.dart | 2 -- lib/providers/equipment_profile_provider.dart | 2 +- lib/screens/metering/bloc_metering.dart | 8 ++++---- .../components/measure_button/widget_button_measure.dart | 1 - .../bottom_controls/widget_bottom_controls.dart | 2 +- .../camera_container/bloc_container_camera.dart | 2 +- .../components/camera_view/widget_camera_view.dart | 2 +- .../camera_container/widget_container_camera.dart | 4 ++-- .../shared/metering_top_bar/shape_top_bar_metering.dart | 2 -- .../animated_dialog/widget_dialog_animated.dart | 4 ++-- .../components/dialog_picker/widget_picker_dialog.dart | 1 - .../widget_container_reading_value.dart | 1 - .../calibration_dialog/bloc_dialog_calibration.dart | 2 +- .../dialog_range_picker/widget_dialog_picker_range.dart | 1 - .../widget_container_equipment_profile.dart | 1 - .../widget_list_tile_equipment_profiles.dart | 2 +- .../widget_dialog_picker_primary_color.dart | 2 +- 22 files changed, 27 insertions(+), 30 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 9d2bd61..1d2d7ec 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1 +1,5 @@ -include: package:lint/strict.yaml \ No newline at end of file +include: package:lint/strict.yaml + +analyzer: + exclude: + - "**/generated/**" \ No newline at end of file diff --git a/lib/application.dart b/lib/application.dart index 3f5a11f..cfe00ae 100644 --- a/lib/application.dart +++ b/lib/application.dart @@ -32,7 +32,7 @@ class Application extends StatelessWidget { return FutureBuilder( future: Future.wait([ SharedPreferences.getInstance(), - Platform.isAndroid ? const LightSensorService().hasSensor() : Future.value(false), + if (Platform.isAndroid) const LightSensorService().hasSensor() else Future.value(false), ]), builder: (_, snapshot) { if (snapshot.data != null) { @@ -40,7 +40,7 @@ class Application extends StatelessWidget { providers: [ Provider.value(value: env.copyWith(hasLightSensor: snapshot.data![1] as bool)), Provider( - create: (_) => UserPreferencesService(snapshot.data![0] as SharedPreferences)), + create: (_) => UserPreferencesService(snapshot.data![0] as SharedPreferences),), Provider(create: (_) => const CaffeineService()), Provider(create: (_) => const HapticsService()), Provider(create: (_) => PermissionsService()), diff --git a/lib/data/models/exposure_pair.dart b/lib/data/models/exposure_pair.dart index d1907a0..9df3ada 100644 --- a/lib/data/models/exposure_pair.dart +++ b/lib/data/models/exposure_pair.dart @@ -7,5 +7,5 @@ class ExposurePair { const ExposurePair(this.aperture, this.shutterSpeed); @override - String toString() => '${aperture.toString()} - ${shutterSpeed.toString()}'; + String toString() => '$aperture - $shutterSpeed'; } diff --git a/lib/data/models/metering_screen_layout_config.dart b/lib/data/models/metering_screen_layout_config.dart index 68ff40e..04b0b82 100644 --- a/lib/data/models/metering_screen_layout_config.dart +++ b/lib/data/models/metering_screen_layout_config.dart @@ -4,7 +4,7 @@ typedef MeteringScreenLayoutConfig = Map; extension MeteringScreenLayoutConfigJson on MeteringScreenLayoutConfig { static MeteringScreenLayoutConfig fromJson(Map data) => data.map( - (key, value) => MapEntry(MeteringScreenLayoutFeature.values[int.parse(key)], value as bool)); + (key, value) => MapEntry(MeteringScreenLayoutFeature.values[int.parse(key)], value as bool),); Map toJson() => map((key, value) => MapEntry(key.index.toString(), value)); } diff --git a/lib/data/shared_prefs_service.dart b/lib/data/shared_prefs_service.dart index 0dd9972..a86a7d1 100644 --- a/lib/data/shared_prefs_service.dart +++ b/lib/data/shared_prefs_service.dart @@ -86,7 +86,9 @@ class UserPreferencesService { MeteringScreenLayoutConfig get meteringScreenLayout { final configJson = _sharedPreferences.getString(_meteringScreenLayoutKey); if (configJson != null) { - return MeteringScreenLayoutConfigJson.fromJson(json.decode(configJson)); + return MeteringScreenLayoutConfigJson.fromJson( + json.decode(configJson) as Map, + ); } else { return { MeteringScreenLayoutFeature.extremeExposurePairs: true, diff --git a/lib/interactors/metering_interactor.dart b/lib/interactors/metering_interactor.dart index 1948b97..0134b34 100644 --- a/lib/interactors/metering_interactor.dart +++ b/lib/interactors/metering_interactor.dart @@ -58,8 +58,6 @@ class MeteringInteractor { AppSettings.openAppSettings(); } - void enableHaptics(bool enable) => _userPreferencesService.haptics = enable; - Future hasAmbientLightSensor() async { if (Platform.isAndroid) { return _lightSensorService.hasSensor(); diff --git a/lib/providers/equipment_profile_provider.dart b/lib/providers/equipment_profile_provider.dart index 610ecd7..c55b7d5 100644 --- a/lib/providers/equipment_profile_provider.dart +++ b/lib/providers/equipment_profile_provider.dart @@ -72,7 +72,7 @@ class EquipmentProfileProviderState extends State { ndValues: NdValue.values, shutterSpeedValues: ShutterSpeedValue.values, isoValues: IsoValue.values, - )); + ),); _refreshSavedProfiles(); } diff --git a/lib/screens/metering/bloc_metering.dart b/lib/screens/metering/bloc_metering.dart index b5901c3..573e0e5 100644 --- a/lib/screens/metering/bloc_metering.dart +++ b/lib/screens/metering/bloc_metering.dart @@ -158,12 +158,12 @@ class MeteringBloc extends Bloc { iso: _iso, nd: _nd, exposurePairs: _buildExposureValues(ev), - )); + ),); } List _buildExposureValues(double ev) { if (ev.isNaN || ev.isInfinite) { - return List.empty(growable: false); + return List.empty(); } /// Depending on the `stopType` the exposure pairs list length is multiplied by 1,2 or 3 @@ -200,11 +200,11 @@ class MeteringBloc extends Bloc { } final int itemsCount = min(_apertureValues.length + shutterSpeedOffset, - _shutterSpeedValues.length + apertureOffset) - + _shutterSpeedValues.length + apertureOffset,) - max(apertureOffset, shutterSpeedOffset); if (itemsCount < 0) { - return List.empty(growable: false); + return List.empty(); } return List.generate( itemsCount, diff --git a/lib/screens/metering/components/bottom_controls/components/measure_button/widget_button_measure.dart b/lib/screens/metering/components/bottom_controls/components/measure_button/widget_button_measure.dart index 352990a..3ea6d1f 100644 --- a/lib/screens/metering/components/bottom_controls/components/measure_button/widget_button_measure.dart +++ b/lib/screens/metering/components/bottom_controls/components/measure_button/widget_button_measure.dart @@ -73,7 +73,6 @@ class _MeteringMeasureButtonState extends State { /// This key is needed to make indicator start from the same point every time key: ValueKey(widget.isMetering), color: Theme.of(context).colorScheme.onSurface, - strokeWidth: Dimens.grid4, value: widget.isMetering ? null : 1, ), ), diff --git a/lib/screens/metering/components/bottom_controls/widget_bottom_controls.dart b/lib/screens/metering/components/bottom_controls/widget_bottom_controls.dart index 9bb4c53..ed7207d 100644 --- a/lib/screens/metering/components/bottom_controls/widget_bottom_controls.dart +++ b/lib/screens/metering/components/bottom_controls/widget_bottom_controls.dart @@ -43,7 +43,7 @@ class MeteringBottomControls extends StatelessWidget { onPressed: onSwitchEvSourceType, icon: Icon(context.watch() != EvSourceType.camera ? Icons.camera_rear - : Icons.wb_incandescent), + : Icons.wb_incandescent,), ), ), ) diff --git a/lib/screens/metering/components/camera_container/bloc_container_camera.dart b/lib/screens/metering/components/camera_container/bloc_container_camera.dart index 1dee549..7a588fa 100644 --- a/lib/screens/metering/components/camera_container/bloc_container_camera.dart +++ b/lib/screens/metering/components/camera_container/bloc_container_camera.dart @@ -167,7 +167,7 @@ class CameraContainerBloc extends EvSourceBlocBase _takePhoto() async { diff --git a/lib/screens/metering/components/camera_container/components/camera_view/widget_camera_view.dart b/lib/screens/metering/components/camera_container/components/camera_view/widget_camera_view.dart index 845d9af..e443ad1 100644 --- a/lib/screens/metering/components/camera_container/components/camera_view/widget_camera_view.dart +++ b/lib/screens/metering/components/camera_container/components/camera_view/widget_camera_view.dart @@ -5,7 +5,7 @@ import 'package:flutter/services.dart'; class CameraView extends StatelessWidget { final CameraController controller; - const CameraView({required this.controller, Key? key}) : super(key: key); + const CameraView({required this.controller, super.key}); @override Widget build(BuildContext context) { diff --git a/lib/screens/metering/components/camera_container/widget_container_camera.dart b/lib/screens/metering/components/camera_container/widget_container_camera.dart index 46f4278..fa2ff63 100644 --- a/lib/screens/metering/components/camera_container/widget_container_camera.dart +++ b/lib/screens/metering/components/camera_container/widget_container_camera.dart @@ -103,7 +103,7 @@ class CameraContainer extends StatelessWidget { } class _CameraViewBuilder extends StatelessWidget { - const _CameraViewBuilder({Key? key}) : super(key: key); + const _CameraViewBuilder(); @override Widget build(BuildContext context) { @@ -156,7 +156,7 @@ class _CameraControlsBuilder extends StatelessWidget { context.read().add( state.error == CameraErrorType.permissionNotGranted ? const OpenAppSettingsEvent() - : const InitializeEvent()); + : const InitializeEvent(),); }, ); } else { diff --git a/lib/screens/metering/components/shared/metering_top_bar/shape_top_bar_metering.dart b/lib/screens/metering/components/shared/metering_top_bar/shape_top_bar_metering.dart index 28a9226..c8f04fa 100644 --- a/lib/screens/metering/components/shared/metering_top_bar/shape_top_bar_metering.dart +++ b/lib/screens/metering/components/shared/metering_top_bar/shape_top_bar_metering.dart @@ -59,7 +59,6 @@ class MeteringTopBarShape extends CustomPainter { path.arcToPoint( Offset(appendixWidth, size.height + appendixHeight + allowedRadius), radius: circularRadius, - clockwise: true, ); path.lineTo(appendixWidth, size.height - allowedRadius); path.arcToPoint( @@ -98,7 +97,6 @@ class MeteringTopBarShape extends CustomPainter { Offset(allowedRadius, -allowedRadius), radius: Radius.circular(allowedRadius), rotation: 90, - clockwise: true, ); // Right side with bottom corner diff --git a/lib/screens/metering/components/shared/readings_container/components/animated_dialog_picker/components/animated_dialog/widget_dialog_animated.dart b/lib/screens/metering/components/shared/readings_container/components/animated_dialog_picker/components/animated_dialog/widget_dialog_animated.dart index 42d1cb2..7e19557 100644 --- a/lib/screens/metering/components/shared/readings_container/components/animated_dialog_picker/components/animated_dialog/widget_dialog_animated.dart +++ b/lib/screens/metering/components/shared/readings_container/components/animated_dialog_picker/components/animated_dialog/widget_dialog_animated.dart @@ -71,7 +71,7 @@ class AnimatedDialogState extends State with SingleTickerProvide 0.8, curve: Curves.ease, ), - )); + ),); _openedOpacityAnimation = Tween( begin: 0, end: 1, @@ -82,7 +82,7 @@ class AnimatedDialogState extends State with SingleTickerProvide 1.0, curve: Curves.easeInOut, ), - )); + ),); WidgetsBinding.instance.addPostFrameCallback((_) { final mediaQuery = MediaQuery.of(context); diff --git a/lib/screens/metering/components/shared/readings_container/components/animated_dialog_picker/components/dialog_picker/widget_picker_dialog.dart b/lib/screens/metering/components/shared/readings_container/components/animated_dialog_picker/components/dialog_picker/widget_picker_dialog.dart index a5d6d45..fcc58d3 100644 --- a/lib/screens/metering/components/shared/readings_container/components/animated_dialog_picker/components/dialog_picker/widget_picker_dialog.dart +++ b/lib/screens/metering/components/shared/readings_container/components/animated_dialog_picker/components/dialog_picker/widget_picker_dialog.dart @@ -110,7 +110,6 @@ class _DialogPickerState extends State> { padding: Dimens.dialogActionsPadding, child: Row( crossAxisAlignment: CrossAxisAlignment.end, - mainAxisSize: MainAxisSize.max, children: [ const Spacer(), TextButton( diff --git a/lib/screens/metering/components/shared/readings_container/components/reading_value_container/widget_container_reading_value.dart b/lib/screens/metering/components/shared/readings_container/components/reading_value_container/widget_container_reading_value.dart index 25b1217..b40f666 100644 --- a/lib/screens/metering/components/shared/readings_container/components/reading_value_container/widget_container_reading_value.dart +++ b/lib/screens/metering/components/shared/readings_container/components/reading_value_container/widget_container_reading_value.dart @@ -42,7 +42,6 @@ class ReadingValueContainer extends StatelessWidget { padding: const EdgeInsets.all(Dimens.paddingM), child: Column( crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: _items, ), diff --git a/lib/screens/settings/components/metering/components/calibration/components/calibration_dialog/bloc_dialog_calibration.dart b/lib/screens/settings/components/metering/components/calibration/components/calibration_dialog/bloc_dialog_calibration.dart index 6003396..0c819fd 100644 --- a/lib/screens/settings/components/metering/components/calibration/components/calibration_dialog/bloc_dialog_calibration.dart +++ b/lib/screens/settings/components/metering/components/calibration/components/calibration_dialog/bloc_dialog_calibration.dart @@ -36,7 +36,7 @@ class CalibrationDialogBloc extends Bloc extends State children: [ ListTile( title: Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ _AnimatedNameLeading(controller: _controller), const SizedBox(width: Dimens.grid8), diff --git a/lib/screens/settings/components/metering/components/equipment_profiles/widget_list_tile_equipment_profiles.dart b/lib/screens/settings/components/metering/components/equipment_profiles/widget_list_tile_equipment_profiles.dart index ab4167a..0fed028 100644 --- a/lib/screens/settings/components/metering/components/equipment_profiles/widget_list_tile_equipment_profiles.dart +++ b/lib/screens/settings/components/metering/components/equipment_profiles/widget_list_tile_equipment_profiles.dart @@ -13,7 +13,7 @@ class EquipmentProfilesListTile extends StatelessWidget { title: Text(S.of(context).equipmentProfiles), onTap: () { Navigator.of(context).push( - MaterialPageRoute(builder: (_) => const EquipmentProfilesScreen())); + MaterialPageRoute(builder: (_) => const EquipmentProfilesScreen()),); }, ); } diff --git a/lib/screens/settings/components/theme/components/primary_color/components/primary_color_picker_dialog/widget_dialog_picker_primary_color.dart b/lib/screens/settings/components/theme/components/primary_color/components/primary_color_picker_dialog/widget_dialog_picker_primary_color.dart index 58d357e..85c897d 100644 --- a/lib/screens/settings/components/theme/components/primary_color/components/primary_color_picker_dialog/widget_dialog_picker_primary_color.dart +++ b/lib/screens/settings/components/theme/components/primary_color/components/primary_color_picker_dialog/widget_dialog_picker_primary_color.dart @@ -68,7 +68,7 @@ class _PrimaryColorDialogPickerState extends State { ], ), ], - )), + ),), actionsPadding: Dimens.dialogActionsPadding, actions: [ TextButton(