A simple camera wrapper built on top of camera. Designed for straighforward camera setup and control on Android and iOS.


Features

  • CameraManager for camera setup and control
  • Support for switching cameras
  • Picture capture
  • Fully testable via injectable dependencies
  • Optional customizable preview widget

Preview

Getting Started

1. Add dependency

dependencies:
  camera_plus: ^0.1.0

2. Platform setup

Android

Add required permissions to android/app/src/main/AndroidManifest.xml:

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

Add usage descriptions to ios/Runner/Info.plist:

<key>NSCameraUsageDescription</key>
<string>We need access to the camera to take photos.</string>

Usage

Initialize the manager

final manager = CameraManager();

await manager.init(); // must be called before use

Display a preview

Build your own widget using the included state, or use the CameraView widget (see example):

ValueListenableBuilder<CameraState>(
  valueListenable: manager.state,
  builder: (context, state, _) {
    if (state.error != null) {
      return Text('Camera error: ${state.error}');
    }

    if (!state.isReady) {
      return const Center(child: CircularProgressIndicator());
    }

    return AspectRatio(
      aspectRatio: 1 / state.controller!.value.aspectRatio,
      child: CameraPreview(state.controller!),
    );
  },
)

Switch camera

await manager.switchCamera();

Capture image

final file = await manager.takePicture();
print('Saved at ${file.path}');

Roadmap

  • Zoom, flash, focus, and exposure controls
  • Video recording

License

Libraries

camera_plus