ML-53 Unsupported operation: Infinity or NaN toInt (#54)

added `isNan` & `isInfinite` checks
This commit is contained in:
Vadim 2023-05-04 12:49:26 +02:00 committed by GitHub
parent 6232ad555a
commit 0583b07cb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View file

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

View file

@ -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}',