flutter_camera_widget 1.2.0-alpha.1
flutter_camera_widget: ^1.2.0-alpha.1 copied to clipboard
A customizable Flutter package that displays a basic camera UI, with video and photo preview.
This package provides a customizable camera overlay to record videos or take pictures, with many features such as media preview, gallery saving...
This package is in alpha version, future updates may be breaking changes.
Features #
- Camera display;
- Photo capturing;
- Video recording;
- Media visualization;
- Media preview;
- Gallery saver;
- Flash mode;
- Custom icons with custom handlers to make the best user experience;
- Camera zooming;
- Custom colouring;
Getting started #
Before we start, make sure to get all required dependencies :
flutter pub get;
Now, you can import the camera widget :
import 'package:flutter_camera_widget/cameraWidget.dart';
Usage #
Before we can use the Camera widget, make sure to have a list of all available cameras, by adding these lines :
import 'package:camera/camera.dart' as camera;
List<camera.CameraDescription> cameras = [];
// some cool code you want to add here...
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
cameras = await availableCameras(); // you have now all your available cameras in the list !
}
To use the Camera widget, use :
Camera(
cameras: cameras,
);
Now you can see that there is nothing more than a camera, and the photo mode doesn't even save to gallery !
This is because all parameters have been set to false.
For a more functionnal Camera widget, you can add parameters :
Camera(
cameras: cameras,
flash: true, // displays flash icon on top to enable/disable flash.
video: true,
focus: true,
zoom: true,
resolution: ResolutionPreset.high,
saveToGalleryOnCapture: true,
backgroundColor: Colors.black,
primaryColor: Colors.blue,
accentColor: Colors.greenAccent,
showCapturedMedias: true,
)