mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 07:20:39 +00:00
dart fixes
This commit is contained in:
parent
636b1fa9bf
commit
9ef55be2df
22 changed files with 27 additions and 30 deletions
|
@ -1 +1,5 @@
|
||||||
include: package:lint/strict.yaml
|
include: package:lint/strict.yaml
|
||||||
|
|
||||||
|
analyzer:
|
||||||
|
exclude:
|
||||||
|
- "**/generated/**"
|
|
@ -32,7 +32,7 @@ class Application extends StatelessWidget {
|
||||||
return FutureBuilder(
|
return FutureBuilder(
|
||||||
future: Future.wait([
|
future: Future.wait([
|
||||||
SharedPreferences.getInstance(),
|
SharedPreferences.getInstance(),
|
||||||
Platform.isAndroid ? const LightSensorService().hasSensor() : Future.value(false),
|
if (Platform.isAndroid) const LightSensorService().hasSensor() else Future.value(false),
|
||||||
]),
|
]),
|
||||||
builder: (_, snapshot) {
|
builder: (_, snapshot) {
|
||||||
if (snapshot.data != null) {
|
if (snapshot.data != null) {
|
||||||
|
@ -40,7 +40,7 @@ class Application extends StatelessWidget {
|
||||||
providers: [
|
providers: [
|
||||||
Provider.value(value: env.copyWith(hasLightSensor: snapshot.data![1] as bool)),
|
Provider.value(value: env.copyWith(hasLightSensor: snapshot.data![1] as bool)),
|
||||||
Provider(
|
Provider(
|
||||||
create: (_) => UserPreferencesService(snapshot.data![0] as SharedPreferences)),
|
create: (_) => UserPreferencesService(snapshot.data![0] as SharedPreferences),),
|
||||||
Provider(create: (_) => const CaffeineService()),
|
Provider(create: (_) => const CaffeineService()),
|
||||||
Provider(create: (_) => const HapticsService()),
|
Provider(create: (_) => const HapticsService()),
|
||||||
Provider(create: (_) => PermissionsService()),
|
Provider(create: (_) => PermissionsService()),
|
||||||
|
|
|
@ -7,5 +7,5 @@ class ExposurePair {
|
||||||
const ExposurePair(this.aperture, this.shutterSpeed);
|
const ExposurePair(this.aperture, this.shutterSpeed);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => '${aperture.toString()} - ${shutterSpeed.toString()}';
|
String toString() => '$aperture - $shutterSpeed';
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ typedef MeteringScreenLayoutConfig = Map<MeteringScreenLayoutFeature, bool>;
|
||||||
|
|
||||||
extension MeteringScreenLayoutConfigJson on MeteringScreenLayoutConfig {
|
extension MeteringScreenLayoutConfigJson on MeteringScreenLayoutConfig {
|
||||||
static MeteringScreenLayoutConfig fromJson(Map<String, dynamic> data) => data.map(
|
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));
|
Map<String, dynamic> toJson() => map((key, value) => MapEntry(key.index.toString(), value));
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,9 @@ class UserPreferencesService {
|
||||||
MeteringScreenLayoutConfig get meteringScreenLayout {
|
MeteringScreenLayoutConfig get meteringScreenLayout {
|
||||||
final configJson = _sharedPreferences.getString(_meteringScreenLayoutKey);
|
final configJson = _sharedPreferences.getString(_meteringScreenLayoutKey);
|
||||||
if (configJson != null) {
|
if (configJson != null) {
|
||||||
return MeteringScreenLayoutConfigJson.fromJson(json.decode(configJson));
|
return MeteringScreenLayoutConfigJson.fromJson(
|
||||||
|
json.decode(configJson) as Map<String, dynamic>,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
MeteringScreenLayoutFeature.extremeExposurePairs: true,
|
MeteringScreenLayoutFeature.extremeExposurePairs: true,
|
||||||
|
|
|
@ -58,8 +58,6 @@ class MeteringInteractor {
|
||||||
AppSettings.openAppSettings();
|
AppSettings.openAppSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void enableHaptics(bool enable) => _userPreferencesService.haptics = enable;
|
|
||||||
|
|
||||||
Future<bool> hasAmbientLightSensor() async {
|
Future<bool> hasAmbientLightSensor() async {
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
return _lightSensorService.hasSensor();
|
return _lightSensorService.hasSensor();
|
||||||
|
|
|
@ -72,7 +72,7 @@ class EquipmentProfileProviderState extends State<EquipmentProfileProvider> {
|
||||||
ndValues: NdValue.values,
|
ndValues: NdValue.values,
|
||||||
shutterSpeedValues: ShutterSpeedValue.values,
|
shutterSpeedValues: ShutterSpeedValue.values,
|
||||||
isoValues: IsoValue.values,
|
isoValues: IsoValue.values,
|
||||||
));
|
),);
|
||||||
_refreshSavedProfiles();
|
_refreshSavedProfiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,12 +158,12 @@ class MeteringBloc extends Bloc<MeteringEvent, MeteringState> {
|
||||||
iso: _iso,
|
iso: _iso,
|
||||||
nd: _nd,
|
nd: _nd,
|
||||||
exposurePairs: _buildExposureValues(ev),
|
exposurePairs: _buildExposureValues(ev),
|
||||||
));
|
),);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ExposurePair> _buildExposureValues(double ev) {
|
List<ExposurePair> _buildExposureValues(double ev) {
|
||||||
if (ev.isNaN || ev.isInfinite) {
|
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
|
/// 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,
|
final int itemsCount = min(_apertureValues.length + shutterSpeedOffset,
|
||||||
_shutterSpeedValues.length + apertureOffset) -
|
_shutterSpeedValues.length + apertureOffset,) -
|
||||||
max(apertureOffset, shutterSpeedOffset);
|
max(apertureOffset, shutterSpeedOffset);
|
||||||
|
|
||||||
if (itemsCount < 0) {
|
if (itemsCount < 0) {
|
||||||
return List.empty(growable: false);
|
return List.empty();
|
||||||
}
|
}
|
||||||
return List.generate(
|
return List.generate(
|
||||||
itemsCount,
|
itemsCount,
|
||||||
|
|
|
@ -73,7 +73,6 @@ class _MeteringMeasureButtonState extends State<MeteringMeasureButton> {
|
||||||
/// This key is needed to make indicator start from the same point every time
|
/// This key is needed to make indicator start from the same point every time
|
||||||
key: ValueKey(widget.isMetering),
|
key: ValueKey(widget.isMetering),
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
strokeWidth: Dimens.grid4,
|
|
||||||
value: widget.isMetering ? null : 1,
|
value: widget.isMetering ? null : 1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -43,7 +43,7 @@ class MeteringBottomControls extends StatelessWidget {
|
||||||
onPressed: onSwitchEvSourceType,
|
onPressed: onSwitchEvSourceType,
|
||||||
icon: Icon(context.watch<EvSourceType>() != EvSourceType.camera
|
icon: Icon(context.watch<EvSourceType>() != EvSourceType.camera
|
||||||
? Icons.camera_rear
|
? Icons.camera_rear
|
||||||
: Icons.wb_incandescent),
|
: Icons.wb_incandescent,),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
@ -167,7 +167,7 @@ class CameraContainerBloc extends EvSourceBlocBase<CameraContainerEvent, CameraC
|
||||||
exposureOffsetRange: _exposureOffsetRange!,
|
exposureOffsetRange: _exposureOffsetRange!,
|
||||||
exposureOffsetStep: _exposureStep,
|
exposureOffsetStep: _exposureStep,
|
||||||
currentExposureOffset: _currentExposureOffset,
|
currentExposureOffset: _currentExposureOffset,
|
||||||
));
|
),);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<double?> _takePhoto() async {
|
Future<double?> _takePhoto() async {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import 'package:flutter/services.dart';
|
||||||
class CameraView extends StatelessWidget {
|
class CameraView extends StatelessWidget {
|
||||||
final CameraController controller;
|
final CameraController controller;
|
||||||
|
|
||||||
const CameraView({required this.controller, Key? key}) : super(key: key);
|
const CameraView({required this.controller, super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
|
@ -103,7 +103,7 @@ class CameraContainer extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CameraViewBuilder extends StatelessWidget {
|
class _CameraViewBuilder extends StatelessWidget {
|
||||||
const _CameraViewBuilder({Key? key}) : super(key: key);
|
const _CameraViewBuilder();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -156,7 +156,7 @@ class _CameraControlsBuilder extends StatelessWidget {
|
||||||
context.read<CameraContainerBloc>().add(
|
context.read<CameraContainerBloc>().add(
|
||||||
state.error == CameraErrorType.permissionNotGranted
|
state.error == CameraErrorType.permissionNotGranted
|
||||||
? const OpenAppSettingsEvent()
|
? const OpenAppSettingsEvent()
|
||||||
: const InitializeEvent());
|
: const InitializeEvent(),);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -59,7 +59,6 @@ class MeteringTopBarShape extends CustomPainter {
|
||||||
path.arcToPoint(
|
path.arcToPoint(
|
||||||
Offset(appendixWidth, size.height + appendixHeight + allowedRadius),
|
Offset(appendixWidth, size.height + appendixHeight + allowedRadius),
|
||||||
radius: circularRadius,
|
radius: circularRadius,
|
||||||
clockwise: true,
|
|
||||||
);
|
);
|
||||||
path.lineTo(appendixWidth, size.height - allowedRadius);
|
path.lineTo(appendixWidth, size.height - allowedRadius);
|
||||||
path.arcToPoint(
|
path.arcToPoint(
|
||||||
|
@ -98,7 +97,6 @@ class MeteringTopBarShape extends CustomPainter {
|
||||||
Offset(allowedRadius, -allowedRadius),
|
Offset(allowedRadius, -allowedRadius),
|
||||||
radius: Radius.circular(allowedRadius),
|
radius: Radius.circular(allowedRadius),
|
||||||
rotation: 90,
|
rotation: 90,
|
||||||
clockwise: true,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Right side with bottom corner
|
// Right side with bottom corner
|
||||||
|
|
|
@ -71,7 +71,7 @@ class AnimatedDialogState extends State<AnimatedDialog> with SingleTickerProvide
|
||||||
0.8,
|
0.8,
|
||||||
curve: Curves.ease,
|
curve: Curves.ease,
|
||||||
),
|
),
|
||||||
));
|
),);
|
||||||
_openedOpacityAnimation = Tween<double>(
|
_openedOpacityAnimation = Tween<double>(
|
||||||
begin: 0,
|
begin: 0,
|
||||||
end: 1,
|
end: 1,
|
||||||
|
@ -82,7 +82,7 @@ class AnimatedDialogState extends State<AnimatedDialog> with SingleTickerProvide
|
||||||
1.0,
|
1.0,
|
||||||
curve: Curves.easeInOut,
|
curve: Curves.easeInOut,
|
||||||
),
|
),
|
||||||
));
|
),);
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
final mediaQuery = MediaQuery.of(context);
|
final mediaQuery = MediaQuery.of(context);
|
||||||
|
|
|
@ -110,7 +110,6 @@ class _DialogPickerState<T> extends State<DialogPicker<T>> {
|
||||||
padding: Dimens.dialogActionsPadding,
|
padding: Dimens.dialogActionsPadding,
|
||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children: [
|
children: [
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
TextButton(
|
TextButton(
|
||||||
|
|
|
@ -42,7 +42,6 @@ class ReadingValueContainer extends StatelessWidget {
|
||||||
padding: const EdgeInsets.all(Dimens.paddingM),
|
padding: const EdgeInsets.all(Dimens.paddingM),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: _items,
|
children: _items,
|
||||||
),
|
),
|
||||||
|
|
|
@ -36,7 +36,7 @@ class CalibrationDialogBloc extends Bloc<CalibrationDialogEvent, CalibrationDial
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onLightSensorEvCalibrationChanged(
|
void _onLightSensorEvCalibrationChanged(
|
||||||
LightSensorEvCalibrationChangedEvent event, Emitter emit) {
|
LightSensorEvCalibrationChangedEvent event, Emitter emit,) {
|
||||||
_lightSensorEvCalibration = event.value;
|
_lightSensorEvCalibration = event.value;
|
||||||
emit(CalibrationDialogState(_cameraEvCalibration, _lightSensorEvCalibration));
|
emit(CalibrationDialogState(_cameraEvCalibration, _lightSensorEvCalibration));
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,6 @@ class _DialogRangePickerState<T extends PhotographyValue> extends State<DialogRa
|
||||||
_start.toDouble(),
|
_start.toDouble(),
|
||||||
_end.toDouble(),
|
_end.toDouble(),
|
||||||
),
|
),
|
||||||
min: 0,
|
|
||||||
max: widget.values.length.toDouble() - 1,
|
max: widget.values.length.toDouble() - 1,
|
||||||
divisions: widget.values.length - 1,
|
divisions: widget.values.length - 1,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
|
|
|
@ -72,7 +72,6 @@ class EquipmentProfileContainerState extends State<EquipmentProfileContainer>
|
||||||
children: [
|
children: [
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Row(
|
title: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
_AnimatedNameLeading(controller: _controller),
|
_AnimatedNameLeading(controller: _controller),
|
||||||
const SizedBox(width: Dimens.grid8),
|
const SizedBox(width: Dimens.grid8),
|
||||||
|
|
|
@ -13,7 +13,7 @@ class EquipmentProfilesListTile extends StatelessWidget {
|
||||||
title: Text(S.of(context).equipmentProfiles),
|
title: Text(S.of(context).equipmentProfiles),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).push<EquipmentProfileData>(
|
Navigator.of(context).push<EquipmentProfileData>(
|
||||||
MaterialPageRoute(builder: (_) => const EquipmentProfilesScreen()));
|
MaterialPageRoute(builder: (_) => const EquipmentProfilesScreen()),);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ class _PrimaryColorDialogPickerState extends State<PrimaryColorDialogPicker> {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)),
|
),),
|
||||||
actionsPadding: Dimens.dialogActionsPadding,
|
actionsPadding: Dimens.dialogActionsPadding,
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
|
|
Loading…
Reference in a new issue