Open Source

Flutter package

camera_extended

Flutter's camera plugin, forked to add native aspect-ratio capture — 16:9, 4:3 and 1:1 at the sensor level on Android and iOS.

v1.2.522.7k / month16 likesBSD-3-ClauseAndroid · iOS16:9 · 4:3 · 1:1

camera_extended

A drop-in fork of the official camera plugin that adds native aspect-ratio capture — what it changes, why, and how to get your first preview running.

source: packages/camera/README.md

Overview

What it is

camera_extended is a fork of Flutter's official camera plugin that adds native aspect-ratio support (16:9, 4:3, 1:1). Instead of cropping a frame after capture, it configures the camera at the native sensor level through CameraX on Android and AVFoundation on iOS — so a 1:1 request yields a genuinely wider field of view rather than a centre crop of a 4:3 or 16:9 frame.

Sensor-level, not a crop

The standard camera package only displays at the camera's native ratio. This fork requests a specific aspect ratio from the sensor: on Android CameraX picks a native format (many devices expose native square formats such as 1088×1088), and on iOS AVFoundation selects the closest matching format, falling back to 4:3 for 1:1.

  • Native aspect-ratio selection — 16:9, 4:3 and 1:1 configured at the sensor level, not a post-capture crop
  • Native 1:1 square on Android (e.g. 1088×1088, 720×720); falls back to 4:3 on iOS
  • Wider field of view with 4:3 or 1:1 instead of a centre crop of a 16:9 frame
  • Drop-in replacement — the full official camera API plus the aspect-ratio additions
  • takePictureAsBytes() returns a Uint8List directly, skipping file I/O for ML pipelines and uploads
  • Per-device video stabilization via getSupportedVideoStabilizationModes() and setVideoStabilizationMode()

Compatibility

Drop-in for camera

camera_extended is API-compatible with the official camera package — the same CameraController, CameraPreview, capture and video methods behave identically. It replaces camera in your dependencies; the only additions are the optional aspectRatio constructor parameter, the targetAspectRatio getter, takePictureAsBytes(), the video-stabilization methods and the CameraAspectRatio enum. Migrating is a dependency swap plus an import change.

Migrationdart
# 1. Swap the dependency in pubspec.yaml
# -  camera: ^0.11.0
# +  camera_extended: ^1.2.4

// 2. Update the import
import 'package:camera_extended/camera_extended.dart';

// 3. Optionally request an aspect ratio
CameraController(
  camera,
  ResolutionPreset.high,
  aspectRatio: CameraAspectRatio.ratio4x3,
);

Setup

Installation

Add the dependency to your pubspec.yaml in place of camera:

pubspec.yamlyaml
dependencies:
  camera_extended: ^1.2.4

Or add it from the command line:

bash
flutter pub add camera_extended

Version

The current published version is 1.2.4. The README install snippet pins ^1.2.0, which resolves to the same release. The package requires Dart SDK ^3.9.0 and Flutter >=3.35.0, and supports Android SDK 24+ and iOS 13.0+.

First capture

Quickstart

Enumerate the cameras with availableCameras(), create a CameraController with the aspect ratio you want, call initialize(), then render CameraPreview and capture with takePicture().

Basic usagedart
import 'package:camera_extended/camera_extended.dart';

late List<CameraDescription> cameras;

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  cameras = await availableCameras();
  runApp(const MyApp());
}

// Create a controller with a native aspect ratio.
final controller = CameraController(
  cameras.first,
  ResolutionPreset.high,
  enableAudio: false,
  aspectRatio: CameraAspectRatio.ratio4x3, // sensor-level ratio
);

await controller.initialize();

// Show the live preview: CameraPreview(controller)
// Capture a still image:
final XFile photo = await controller.takePicture();

Permissions

Add CAMERA (and RECORD_AUDIO for video) to the Android manifest, and NSCameraUsageDescription / NSMicrophoneUsageDescription to the iOS Info.plist before initializing the camera.

Architecture

Sibling packages

camera_extended is a federated plugin. You depend on the single camera_extended package; it pulls in three published siblings that provide the platform interface and the native implementations.

camera_extended_platform_interface

The platform abstraction — hosts the CameraAspectRatio enum and the aspectRatio-aware MediaSettings.

camera_extended_android

Android implementation using CameraX ResolutionSelector / AspectRatioStrategy for native aspect ratios.

camera_extended_ios

iOS implementation using AVFoundation format selection based on the requested aspect ratio.

Keep going

Where next

Let's make something together.

If you have any questions about a new project or other inquiries, feel free to contact us. We will get back to you as soon as possible.

Codigee
We are using cookies. Learn more