2025-05-11 09:50:01 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
2025-05-14 08:10:46 +00:00
|
|
|
import 'package:lightmeter/data/analytics/analytics.dart';
|
2025-05-11 09:50:01 +00:00
|
|
|
|
|
|
|
class CameraInfoService {
|
|
|
|
@visibleForTesting
|
2025-05-11 10:48:10 +00:00
|
|
|
static const cameraInfoPlatformChannel = MethodChannel(
|
|
|
|
"com.vodemn.lightmeter.CameraInfoPlatformChannel.MethodChannel",
|
|
|
|
);
|
2025-05-11 09:50:01 +00:00
|
|
|
|
2025-05-14 08:10:46 +00:00
|
|
|
final LightmeterAnalytics analytics;
|
|
|
|
|
|
|
|
const CameraInfoService(this.analytics);
|
2025-05-11 09:50:01 +00:00
|
|
|
|
|
|
|
Future<int?> mainCameraEfl() async {
|
2025-05-14 08:10:46 +00:00
|
|
|
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;
|
|
|
|
}
|
2025-05-11 09:50:01 +00:00
|
|
|
}
|
|
|
|
}
|