Skip to content

Commit

Permalink
ML-53 Unsupported operation: Infinity or NaN toInt (#54)
Browse files Browse the repository at this point in the history
added `isNan` & `isInfinite` checks
  • Loading branch information
vodemn committed May 4, 2023
1 parent 6232ad5 commit 0583b07
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/screens/metering/bloc_metering.dart
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ class MeteringBloc extends Bloc<MeteringEvent, MeteringState> {
}

List<ExposurePair> _buildExposureValues(double ev) {
if (ev.isNaN || ev.isInfinite) {
return List.empty(growable: false);
}

/// Depending on the `stopType` the exposure pairs list length is multiplied by 1,2 or 3
final int evSteps = (ev * (stopType.index + 1)).round();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ class _EvValueText extends StatelessWidget {

@override
Widget build(BuildContext context) {
if (ev.isNaN || ev.isInfinite) {
return Icon(
Icons.error,
color: Theme.of(context).colorScheme.surface,
);
}

final theme = Theme.of(context);
return Text(
'${ev.toStringAsFixed(1)}\n${S.of(context).ev}',
Expand Down

0 comments on commit 0583b07

Please sign in to comment.