field_of_view 0.0.2 copy "field_of_view: ^0.0.2" to clipboard
field_of_view: ^0.0.2 copied to clipboard

A Flutter plugin to get the camera field of view on Android and iOS.

field_of_view #

A Flutter plugin to get the camera's field of view (FOV) on iOS and Android.

Features #

  • Get horizontal and vertical field of view angles from the back camera
  • No camera permissions required
  • Strongly-typed API using Pigeon
  • Supports iOS and Android

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  field_of_view: ^0.0.1

Usage #

import 'package:field_of_view/field_of_view.dart';

final fov = FieldOfView();

try {
  final response = await fov.getFieldOfView();
  print('Horizontal FOV: ${response.horizontalFov}°');
  print('Vertical FOV: ${response.verticalFov}°');
} on PlatformException catch (e) {
  print('Error: ${e.message}');
}

Response #

The FieldOfViewResponse contains:

Property Type Description
horizontalFov double Horizontal field of view in degrees
verticalFov double Vertical field of view in degrees

Note: The FOV values represent the camera sensor's native orientation (landscape), so horizontal FOV will typically be larger than vertical FOV, regardless of device orientation.

Error handling #

The plugin throws PlatformException with the following error codes:

Code Description
CAMERA_UNAVAILABLE No back camera found on the device
SENSOR_UNAVAILABLE Could not retrieve sensor size information
FOCAL_LENGTH_UNAVAILABLE Could not retrieve focal length information

How it works #

FOV = 2 × atan(sensorSize / (2 × focalLength))
0
likes
155
points
87
downloads

Publisher

verified publishermarkszente.io

Weekly Downloads

A Flutter plugin to get the camera field of view on Android and iOS.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on field_of_view

Packages that implement field_of_view