dart fixes

This commit is contained in:
Vadim 2023-05-11 14:58:57 +02:00
parent 636b1fa9bf
commit 9ef55be2df
22 changed files with 27 additions and 30 deletions

View file

@ -1 +1,5 @@
include: package:lint/strict.yaml
include: package:lint/strict.yaml
analyzer:
exclude:
- "**/generated/**"

View file

@ -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()),

View file

@ -7,5 +7,5 @@ class ExposurePair {
const ExposurePair(this.aperture, this.shutterSpeed);
@override
String toString() => '${aperture.toString()} - ${shutterSpeed.toString()}';
String toString() => '$aperture - $shutterSpeed';
}

View file

@ -4,7 +4,7 @@ typedef MeteringScreenLayoutConfig = Map<MeteringScreenLayoutFeature, bool>;
extension MeteringScreenLayoutConfigJson on MeteringScreenLayoutConfig {
static MeteringScreenLayoutConfig fromJson(Map<String, dynamic> 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<String, dynamic> toJson() => map((key, value) => MapEntry(key.index.toString(), value));
}

View file

@ -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<String, dynamic>,
);
} else {
return {
MeteringScreenLayoutFeature.extremeExposurePairs: true,

View file

@ -58,8 +58,6 @@ class MeteringInteractor {
AppSettings.openAppSettings();
}
void enableHaptics(bool enable) => _userPreferencesService.haptics = enable;
Future<bool> hasAmbientLightSensor() async {
if (Platform.isAndroid) {
return _lightSensorService.hasSensor();

View file

@ -72,7 +72,7 @@ class EquipmentProfileProviderState extends State<EquipmentProfileProvider> {
ndValues: NdValue.values,
shutterSpeedValues: ShutterSpeedValue.values,
isoValues: IsoValue.values,
));
),);
_refreshSavedProfiles();
}

View file

@ -158,12 +158,12 @@ class MeteringBloc extends Bloc<MeteringEvent, MeteringState> {
iso: _iso,
nd: _nd,
exposurePairs: _buildExposureValues(ev),
));
),);
}
List<ExposurePair> _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<MeteringEvent, MeteringState> {
}
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,

View file

@ -73,7 +73,6 @@ class _MeteringMeasureButtonState extends State<MeteringMeasureButton> {
/// 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,
),
),

View file

@ -43,7 +43,7 @@ class MeteringBottomControls extends StatelessWidget {
onPressed: onSwitchEvSourceType,
icon: Icon(context.watch<EvSourceType>() != EvSourceType.camera
? Icons.camera_rear
: Icons.wb_incandescent),
: Icons.wb_incandescent,),
),
),
)

View file

@ -167,7 +167,7 @@ class CameraContainerBloc extends EvSourceBlocBase<CameraContainerEvent, CameraC
exposureOffsetRange: _exposureOffsetRange!,
exposureOffsetStep: _exposureStep,
currentExposureOffset: _currentExposureOffset,
));
),);
}
Future<double?> _takePhoto() async {

View file

@ -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) {

View file

@ -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<CameraContainerBloc>().add(
state.error == CameraErrorType.permissionNotGranted
? const OpenAppSettingsEvent()
: const InitializeEvent());
: const InitializeEvent(),);
},
);
} else {

View file

@ -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

View file

@ -71,7 +71,7 @@ class AnimatedDialogState extends State<AnimatedDialog> with SingleTickerProvide
0.8,
curve: Curves.ease,
),
));
),);
_openedOpacityAnimation = Tween<double>(
begin: 0,
end: 1,
@ -82,7 +82,7 @@ class AnimatedDialogState extends State<AnimatedDialog> with SingleTickerProvide
1.0,
curve: Curves.easeInOut,
),
));
),);
WidgetsBinding.instance.addPostFrameCallback((_) {
final mediaQuery = MediaQuery.of(context);

View file

@ -110,7 +110,6 @@ class _DialogPickerState<T> extends State<DialogPicker<T>> {
padding: Dimens.dialogActionsPadding,
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.max,
children: [
const Spacer(),
TextButton(

View file

@ -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,
),

View file

@ -36,7 +36,7 @@ class CalibrationDialogBloc extends Bloc<CalibrationDialogEvent, CalibrationDial
}
void _onLightSensorEvCalibrationChanged(
LightSensorEvCalibrationChangedEvent event, Emitter emit) {
LightSensorEvCalibrationChangedEvent event, Emitter emit,) {
_lightSensorEvCalibration = event.value;
emit(CalibrationDialogState(_cameraEvCalibration, _lightSensorEvCalibration));
}

View file

@ -64,7 +64,6 @@ class _DialogRangePickerState<T extends PhotographyValue> extends State<DialogRa
_start.toDouble(),
_end.toDouble(),
),
min: 0,
max: widget.values.length.toDouble() - 1,
divisions: widget.values.length - 1,
onChanged: (value) {

View file

@ -72,7 +72,6 @@ class EquipmentProfileContainerState extends State<EquipmentProfileContainer>
children: [
ListTile(
title: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
_AnimatedNameLeading(controller: _controller),
const SizedBox(width: Dimens.grid8),

View file

@ -13,7 +13,7 @@ class EquipmentProfilesListTile extends StatelessWidget {
title: Text(S.of(context).equipmentProfiles),
onTap: () {
Navigator.of(context).push<EquipmentProfileData>(
MaterialPageRoute(builder: (_) => const EquipmentProfilesScreen()));
MaterialPageRoute(builder: (_) => const EquipmentProfilesScreen()),);
},
);
}

View file

@ -68,7 +68,7 @@ class _PrimaryColorDialogPickerState extends State<PrimaryColorDialogPicker> {
],
),
],
)),
),),
actionsPadding: Dimens.dialogActionsPadding,
actions: [
TextButton(