m3_lightmeter/lib/data/camera_info_service.dart
Vadim 7c96b5a47d
ML-220 Show focal length when zooming (#233)
* extract focal length from exif

* added focal length section

* wip

* [android] calculate EFL

* split other platform handlers to separate files

* [ios] calculate EFL

* updated translations

* deleted `focalLengthFromTags`

* fixed unit tests

* [ios] link missing files

* updated Pro features screen

* [ios] fixed signing

* fixed screenshot generator

* updated goldens

* [android] updated store screenshots

* wip

* [ios] updated store screenshots

* enable focal length feature by default

* mock camera focal length for integration tests

* cleanup

* added logging to `CameraInfoService`
2025-05-14 10:26:59 +02:00

33 lines
899 B
Dart

import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:lightmeter/data/analytics/analytics.dart';
class CameraInfoService {
@visibleForTesting
static const cameraInfoPlatformChannel = MethodChannel(
"com.vodemn.lightmeter.CameraInfoPlatformChannel.MethodChannel",
);
final LightmeterAnalytics analytics;
const CameraInfoService(this.analytics);
Future<int?> mainCameraEfl() async {
try {
final focalLength = await cameraInfoPlatformChannel.invokeMethod<double?>('mainCameraEfl');
return focalLength?.round();
} on PlatformException catch (e) {
analytics.logEvent(
e.code,
parameters: {
"message": "${e.message}",
"details": e.details.toString(),
},
);
return null;
} catch (e) {
analytics.logEvent(e.toString());
return null;
}
}
}