manual_camera 0.0.2+1
manual_camera: ^0.0.2+1

Flutter Android iOS

A Flutter plugin for manually controlling the camera on Android devices. All the native functions of the Flutter official Camera plugin are available.

Manual Camera Plugin #

pub package

This plugin is a modified version of the native Flutter camera plugin.

This version allows the definition of manual parameters for the Android camera:

FeatureValuesTypeDescription
enableFlashtrue/falseboolTurn flash on or off
focusDistance0 (auto) - +∞doubleDistance in meters from camera to focused object
iso0 (auto) - +∞intSensor's sensitivity to light
shutterSpeed0 (auto) - +∞int1s / shutterSpeed = duration of the sensor exposure
whiteBalance...WhiteBalancePresetWhite balance Android options

Installation #

First, add manual_camera as a dependency in your pubspec.yaml file.

dependencies:
  flutter:
    sdk: flutter
  manual_camera: ^0.0.2 // add manual_camera plugin

iOS #

Add two rows to the ios/Runner/Info.plist:

  • one with the key Privacy - Camera Usage Description and a usage description.
  • and one with the key Privacy - Microphone Usage Description and a usage description.

Or in text format add the key:

<key>NSCameraUsageDescription</key>
<string>Can I use the camera please?</string>
<key>NSMicrophoneUsageDescription</key>
<string>Can I use the mic please?</string>

Android #

Change the minimum Android sdk version to 21 (or higher) in your android/app/build.gradle file.

minSdkVersion 21

Example #

Here is a small example flutter app displaying a full screen camera preview.

import 'dart:async';
import 'package:manual_camera/camera.dart';
import 'package:camera/camera.dart';

List<CameraDescription> cameras;

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

class CameraApp extends StatefulWidget {
  @override
  _CameraAppState createState() => _CameraAppState();
}

class _CameraAppState extends State<CameraApp> {
  CameraController controller;

  @override
  void initState() {
    super.initState();
    controller = CameraController(
      cameras[0],
      ResolutionPreset.medium,
      iso: 100,
      shutterSpeed: 30,
      whiteBalance: WhiteBalancePreset.cloudy,
      focusDistance: 0.1,
    );
    controller.initialize().then((_) {
      if (!mounted) {
        return;
      }
      setState(() {});
      Future.delayed(
        Duration(
          milliseconds: 1000,
        ),
      ).then((_) => _cameraController.flash(true));
    });
  }

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

  @override
  Widget build(BuildContext context) {
    if (!controller.value.isInitialized) {
      return Container();
    }
    return AspectRatio(
        aspectRatio:
        controller.value.aspectRatio,
        child: CameraPreview(controller));
  }
}

Note: This plugin is still under development, and some APIs might not be available yet. I hope that in the future IOS manual exposition will also be available.

3
likes
100
pub points
48%
popularity

A Flutter plugin for manually controlling the camera on Android devices. All the native functions of the Flutter official Camera plugin are available.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

afonsocraposo@gmail.com

License

BSD (LICENSE)

Dependencies

flutter

More

Packages that depend on manual_camera