iris_camera 1.0.4 copy "iris_camera: ^1.0.4" to clipboard
iris_camera: ^1.0.4 copied to clipboard

AVFoundation-powered camera toolkit with preview, lens control, and still capture APIs.

iris_camera #

πŸ“Έ iOS + Android camera toolkit for Flutter, powered by AVFoundation and CameraX. Render the native preview, switch lenses, stream frames, capture photos, record video, tune exposure/white balance/torch/zoom, and listen to lifecycle + orientation + AF/AE state – all from Dart.

Platform coverage: iOS + Android. Web backend planned for v2. Other platforms no-op safely.


Highlights #

  • πŸ” Lens discovery & switching – list every lens (front included by default; exclude with includeFrontCameras: false) and reconfigure with switchLens.
  • πŸ–ΌοΈ Native preview widget – IrisCameraPreview wraps AVCaptureVideoPreviewLayer with tap-to-focus + overlay hooks.
  • πŸ“Έ Still capture – capturePhoto with flash/ISO/exposure overrides.
  • πŸŽ›οΈ Pro controls – focus mode/point, exposure mode/point/EV, white balance, frame rate range, torch, zoom, resolution presets.
  • πŸ“‘ Streams – live BGRA image stream, orientation stream, lifecycle state stream, AF/AE state stream.
  • πŸ”§ Lifecycle – explicit initialize/pause/resume/dispose and structured errors via IrisCameraException.
  • πŸŽ₯ Video – start/stop file-based recording (iOS/Android), optional audio.

Install #

flutter pub add iris_camera
import 'package:iris_camera/iris_camera.dart';

final camera = IrisCamera();
final lenses = await camera.listAvailableLenses(); // includeFrontCameras defaults to true
await camera.switchLens(lenses.first.category);
final photo = await camera.capturePhoto(
  options: const PhotoCaptureOptions(flashMode: PhotoFlashMode.auto),
);

Live preview:

final focusController = FocusIndicatorController();

IrisCameraPreview(
  aspectRatio: 3 / 2,
  enableTapToFocus: true,
  showFocusIndicator: true,
  onTapFocus: (point) => camera.setFocus(point: point),
  focusIndicatorController: focusController,
);

iOS setup #

Add to ios/Runner/Info.plist (both are required or the app will crash when accessing camera/mic):

<key>NSCameraUsageDescription</key>
<string>This app needs the camera to capture photos.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app needs the microphone for recording video with audio.</string>

That’s it. Permissions are requested automatically on first use.

Exclude front cameras by calling listAvailableLenses(includeFrontCameras: false).

Android setup #

Add the camera permission to your app manifest (the plugin also declares it for you):

<uses-permission android:name="android.permission.CAMERA" />
<!-- Needed for video with audio -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />

iris_camera will prompt for runtime permission automatically before accessing the camera. The preview is rendered via a native PreviewView, and tap-to-focus works the same as iOS.


API quick reference #

Key methods:

  • listAvailableLenses({includeFrontCameras}) β†’ List<CameraLensDescriptor>
  • switchLens(CameraLensCategory category) β†’ CameraLensDescriptor
  • capturePhoto({PhotoCaptureOptions options}) β†’ Uint8List
  • startVideoRecording({filePath, enableAudio}) β†’ String path
  • stopVideoRecording() β†’ String path
  • Focus: setFocus(point/lensPosition), setFocusMode, focusExposureStateStream
  • Exposure: setExposureMode, setExposurePoint, setExposureOffset, getMin/MaxExposureOffset, getExposureOffsetStepSize
  • Zoom/torch/WB: setZoom, setTorch, setWhiteBalance
  • Frame/format: setFrameRateRange, setResolutionPreset
  • Streams: imageStream, orientationStream, stateStream
  • Lifecycle: initialize, pauseSession, resumeSession, disposeSession
  • Errors: IrisCameraException(code, message, details)

Data classes:

  • CameraLensDescriptor (id, name, position, category, supportsFocus, optional focalLength, fieldOfView)
  • PhotoCaptureOptions (flashMode, exposureDuration, iso)
  • OrientationEvent, CameraStateEvent, FocusExposureStateEvent, IrisImageFrame

Widget:

  • IrisCameraPreview with tap-to-focus + focus indicator styling/control.

iris_camera vs camera (iOS/Android) #

Capability iris_camera camera
Still photos βœ… Shared session JPEG capture βœ…
Live preview widget βœ… IrisCameraPreview (iOS/Android) βœ…
Lens discovery/switching βœ… Enumerate + switch by category (wide/ultraWide/telephoto/etc.), front opt-in βšͺ️ List only (no switching API)
Tap/manual focus βœ… Tap/point focus; iOS also supports lensPosition βœ…
Exposure controls βœ… mode/point/EV/ISO/exposure duration βœ… (mode/point/offset)
White balance override βœ… iOS: temperature/tint; Android: auto/lock only βšͺ️ (not exposed)
Zoom βœ… βœ…
Torch βœ… (torch separate from flash) βœ…
Frame rate range βœ… min/max FPS βšͺ️ limited
Resolution preset βœ… βœ…
Live image stream βœ… BGRA βœ…
Orientation stream βœ… device/video βœ…
AF/AE state stream βœ… βšͺ️ basic focus/exposure mode only
Lifecycle controls βœ… initialize/pause/resume/dispose + state stream βœ… (controller init/dispose)
Video recording βœ… (iOS/Android) βœ…
Web ❌ (planned v2) βœ…

Example flow #

final lenses = await camera.listAvailableLenses();
final tele = lenses.firstWhere(
  (lens) => lens.category == CameraLensCategory.telephoto,
  orElse: () => lenses.first,
);

await camera.switchLens(tele.category);
await camera.initialize();
camera.stateStream.listen((event) => debugPrint('state=${event.state}'));
camera.focusExposureStateStream.listen((event) => debugPrint('af/ae=${event.state}'));

await camera.setExposureMode(ExposureMode.locked);
await camera.setFocusMode(FocusMode.locked);
final photo = await camera.capturePhoto();

License #

MIT β€” see LICENSE.

0
likes
0
points
470
downloads

Publisher

unverified uploader

Weekly Downloads

AVFoundation-powered camera toolkit with preview, lens control, and still capture APIs.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_web_plugins, plugin_platform_interface

More

Packages that depend on iris_camera

Packages that implement iris_camera