분류, 패키지 및 저장소 검색

패키지 상세v1.2.6

camera_extended

원본 비율 지원(16:9, 4:3, 1:1)을 갖춘 확장된 Flutter 카메라 플러그인. 센서 수준의 비율 구성이 가능한 공식 카메라 패키지의 포크입니다.

AndroidiOS
30일 다운로드
1.6만
좋아요
18
Pub 점수
130

패키지 설치

flutter pub add camera_extended

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

camera_extended는 공식 camera 패키지를 16:9, 4:3, 1:1를 포함한 네이티브 비율 지원으로 확장하는 Flutter 플러그인입니다. 더 정밀한 이미지 캡처를 위해 센서 수준의 비율 설정을 가능하게 합니다. 원래 camera 패키지의 포크로 설계되어 호환성을 유지하면서 고급 표시 및 녹화 옵션을 추가했습니다. 다양한 기기에서 일관된 시각적 출력이 필요한 앱에 적합합니다.

사용 사례

  • 고정된 비율로 비디오 녹화
  • 특정 비율의 사진 캡처
  • 정밀한 레이아웃 제어가 필요한 크로스플랫폼 카메라 앱
  • 네이티브 비율 처리가 필요한 앱
  • 정확한 프레임 크기를 갖춘 사용자 정의 카메라 UI

주요 기능

  • 16:9, 4:3 및 1:1 비율 지원
  • 센서 수준의 종횡비 구성
  • Android 및 iOS에서의 네이티브 비율 처리
  • 공식 카메라 패키지의 수정본으로 기능이 향상됨
  • 기존 카메라 워크플로우와의 호환성을 유지합니다

적합한 대상

  • 정확한 비율 제어가 필요한 개발자
  • 일관된 카메라 출력이 필요한 앱
  • 사용자 정의 카메라 인터페이스를 사용하는 프로젝트
  • 다양한 화면 형식을 대상으로 하는 모바일 앱
  • 공식 카메라 기능을 확장하는 팀

고려 사항

  • 비율 선택을 위해 수동 설정이 필요합니다
  • 오래된 장치에서 추가 테스트가 필요할 수 있습니다
  • Android 및 iOS 플랫폼에만 제한됨
  • 하위 카메라 하드웨어 기능에 의존
  • Flutter 팀에서 관리하지 않습니다. 프로덕션 환경에서는 주의해서 사용하세요.

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

camera_extended

pub package likes popularity License: BSD-3

Extended Flutter camera plugin with native aspect ratio support (16:9, 4:3, 1:1).

Fork of the official camera package with sensor-level aspect ratio configuration for both iOS and Android.

Android iOS
Support SDK 24+ iOS 13.0+

Documentation

What's New vs Original Camera Package

Feature camera camera_extended
Aspect Ratio Control No Yes (16:9, 4:3, 1:1)
Native 1:1 Square No Yes (Android)
Sensor-Level Config No Yes
In-Memory Capture No Yes (takePictureAsBytes())
Video Stabilization No Yes (VideoStabilizationMode)

Features

  • Native Aspect Ratio Selection - Configure camera aspect ratio at the sensor level
  • 1:1 Square Format - Native 1:1 on Android (1088x1088), falls back to 4:3 on iOS
  • 4:3 Standard Format - Classic aspect ratio with wider field of view
  • 16:9 Widescreen Format - Modern widescreen ratio
  • In-Memory Capture - takePictureAsBytes() returns raw Uint8List without saving to disk
  • Video Stabilization - Query and set stabilization modes per-device
  • Full compatibility with original camera package API

Why This Package?

The standard camera package doesn't allow you to configure the aspect ratio at the native level. This package extends it to:

  1. Request specific aspect ratios from the camera sensor
  2. Get wider field of view with 4:3 or 1:1 vs 16:9
  3. Capture square photos/videos natively on supported devices
Aspect Ratio Comparison
Ratio Field of View Use Case
16:9 Narrowest Video, Widescreen
4:3 Wider Photos, Standard
1:1 Square Social Media, Profile Photos

Installation

Add to your pubspec.yaml:

dependencies:
  camera_extended: ^1.2.0

Usage

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

late List<CameraDescription> cameras;

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  cameras = await availableCameras();
  runApp(MyApp());
}
Initialize with Aspect Ratio
final controller = CameraController(
  cameras.first,
  ResolutionPreset.high,
  enableAudio: false,
  aspectRatio: CameraAspectRatio.ratio4x3, // NEW: aspect ratio parameter
);

await controller.initialize();
Available Aspect Ratios
enum CameraAspectRatio {
  ratio16x9,    // 16:9 widescreen
  ratio4x3,     // 4:3 standard
  ratio1x1,     // 1:1 square
  ratioDefault, // Camera's default ratio
}
Complete Example
import 'package:camera_extended/camera_extended.dart';
import 'package:flutter/material.dart';

late List<CameraDescription> cameras;

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

class CameraApp extends StatefulWidget {
  const CameraApp({super.key});

  @override
  State<CameraApp> createState() => _CameraAppState();
}

class _CameraAppState extends State<CameraApp> {
  CameraController? _controller;
  CameraAspectRatio _aspectRatio = CameraAspectRatio.ratio4x3;

  @override
  void initState() {
    super.initState();
    _initCamera();
  }

  Future<void> _initCamera() async {
    await _controller?.dispose();

    _controller = CameraController(
      cameras.first,
      ResolutionPreset.high,
      aspectRatio: _aspectRatio, // Set aspect ratio here
    );

    await _controller!.initialize();
    if (mounted) setState(() {});
  }

  void _changeAspectRatio(CameraAspectRatio ratio) {
    setState(() => _aspectRatio = ratio);
    _initCamera(); // Reinitialize camera with new ratio
  }

  @override
  void dispose() {
    _controller?.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Column(
          children: [
            Expanded(
              child: _controller?.value.isInitialized == true
                  ? CameraPreview(_controller!)
                  : const Center(child: CircularProgressIndicator()),
            ),
            Padding(
              padding: const EdgeInsets.all(16),
              child: SegmentedButton<CameraAspectRatio>(
                segments: const [
                  ButtonSegment(value: CameraAspectRatio.ratio16x9, label: Text('16:9')),
                  ButtonSegment(value: CameraAspectRatio.ratio4x3, label: Text('4:3')),
                  ButtonSegment(value: CameraAspectRatio.ratio1x1, label: Text('1:1')),
                ],
                selected: {_aspectRatio},
                onSelectionChanged: (selected) => _changeAspectRatio(selected.first),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
In-Memory Capture

Capture an image directly as bytes without writing to disk — ideal for ML pipelines, image processing, or uploading:

final Uint8List bytes = await controller.takePictureAsBytes();
// Use bytes directly — no file I/O needed
Video Stabilization

Query supported stabilization modes and apply one:

// Check supported modes
final modes = await controller.getSupportedVideoStabilizationModes();

// Apply stabilization
await controller.setVideoStabilizationMode(VideoStabilizationMode.standard);

Available modes: off, standard, cinematic, cinematicExtended (availability depends on device).

Platform Support

Platform 16:9 4:3 1:1
Android Native Native Native (1088x1088)
iOS Native Native Fallback to 4:3
Android

Uses CameraX with ResolutionSelector to request specific aspect ratios. Many Android devices support native 1:1 formats (e.g., 1088x1088, 720x720).

iOS

Uses AVFoundation with format selection based on aspect ratio. iOS cameras typically don't offer native 1:1 formats, so 1:1 falls back to 4:3.

Permissions

Android

Add to AndroidManifest.xml:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
iOS

Add to Info.plist:

<key>NSCameraUsageDescription</key>
<string>Camera access is required for taking photos.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Microphone access is required for recording video.</string>

Migration from camera Package

This package is API-compatible with the original camera package. To migrate:

  1. Replace camera with camera_extended in pubspec.yaml
  2. Update imports: import 'package:camera_extended/camera_extended.dart'
  3. Optionally add aspectRatio parameter to CameraController
// Before (camera package)
import 'package:camera/camera.dart';
CameraController(camera, ResolutionPreset.high);

// After (camera_extended)
import 'package:camera_extended/camera_extended.dart';
CameraController(camera, ResolutionPreset.high, aspectRatio: CameraAspectRatio.ratio4x3);

Handling Lifecycle States

Same as the original camera package - you need to handle lifecycle changes:

@override
void didChangeAppLifecycleState(AppLifecycleState state) {
  final CameraController? cameraController = controller;

  if (cameraController == null || !cameraController.value.isInitialized) {
    return;
  }

  if (state == AppLifecycleState.inactive) {
    cameraController.dispose();
  } else if (state == AppLifecycleState.resumed) {
    _initCamera();
  }
}

Requirements

  • Flutter: >=3.35.0
  • Dart SDK: ^3.9.0

Related Packages

Package Description
camera_extended Main plugin (this package)
camera_extended_android Android implementation
camera_extended_ios iOS implementation
camera_extended_platform_interface Platform interface

License

BSD 3-Clause License - same as the original Flutter camera package.

Credits

Based on the official Flutter camera plugin by the Flutter team.

Extended with native aspect ratio support.


Made with love by Codigee

카테고리

의존성

의존성 목록 4 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.

순위