Flutter plugin to add Camera support inside your project.
CamerAwesome include a lot of useful features like:
- ๐ฒ Live camera flip ( switch between rear & front camera without rebuild ).
- โก๏ธ No init needed, just add CameraAwesome widget !
- โ๏ธ Instant focus.
- ๐ธ Device flash support.
- ๐ Zoom.
- ๐ผ Fullscreen or SizedBox preview support.
- ๐ฎ Complete example.
- ๐ Taking a picture ( of course ๐ ).
- ๐ฅ Video recording (iOS only for now).
Taking photo ๐ธ & record video ๐ฅ | Resolution changing ๐ |
- iOS add these on
ios/Runner/Info.plist
file
<key>NSCameraUsageDescription</key>
<string>Your own description</string>
<key>NSMicrophoneUsageDescription</key>
<string>To enable microphone access when recording video</string>
-
Android
- Set permissions before
<application>
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- Change the minimum SDK version to 21 (or higher) in
android/app/build.gradle
minSdkVersion 21
- Set permissions before
import 'package:camerawesome/camerawesome_plugin.dart';
ValueNotifier is a useful change notifier from Flutter framework. It fires an event on all listener when value changes. Take a look here for ValueNotifier doc
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> with TickerProviderStateMixin {
// [...]
// Notifiers
ValueNotifier<CameraFlashes> _switchFlash = ValueNotifier(CameraFlashes.NONE);
ValueNotifier<Sensors> _sensor = ValueNotifier(Sensors.BACK);
ValueNotifier<CaptureModes> _captureMode = ValueNotifier(CaptureModes.PHOTO);
ValueNotifier<Size> _photoSize = ValueNotifier(null);
// Controllers
PictureController _pictureController = new PictureController();
VideoController _videoController = new VideoController();
// [...]
}
If you want to change a config, all you need is setting the value. CameraAwesome will handle the rest.
Examples:
_switchFlash.value = CameraFlashes.AUTO;
_captureMode.value = CaptureModes.VIDEO;
// [...]
@override
Widget build(BuildContext context) {
return CameraAwesome(
testMode: false,
onPermissionsResult: (bool result) { },
selectDefaultSize: (List<Size> availableSizes) => Size(1920, 1080),
onCameraStarted: () { },
onOrientationChanged: (CameraOrientations newOrientation) { },
zoom: 0.64,
sensor: _sensor,
photoSize: _photoSize,
switchFlashMode: _switchFlash,
captureMode: _captureMode,
fitted: true,
);
};
// [...]
Reveal parameters list
Param | Type | Description | Required |
---|---|---|---|
testMode | boolean |
true to wrap texture | |
onPermissionsResult | OnPermissionsResult |
implement this to have a callback after CameraAwesome asked for permissions | |
selectDefaultSize | OnAvailableSizes |
implement this to select a default size from device available size list | โ |
onCameraStarted | OnCameraStarted |
notify client that camera started | |
onOrientationChanged | OnOrientationChanged |
notify client that orientation changed | |
switchFlashMode | ValueNotifier<CameraFlashes> |
change flash mode | |
enablePinchToZoom | ValueNotifier<bool> |
enable/Disable pinch to zoom | |
zoom | ValueNotifier<double> |
Zoom from native side. Must be between 0 and 1 | |
sensor | ValueNotifier<Sensors> |
sensor to initiate BACK or FRONT | โ |
photoSize | ValueNotifier<Size> |
choose your photo size from the [selectDefaultSize] method | |
captureMode | ValueNotifier<CaptureModes> |
choose capture mode between PHOTO or VIDEO | |
fitted | bool |
whether camera preview must be as big as it needs or cropped to fill with. false by default | |
imagesStreamBuilder | Function |
returns an imageStream when camera has started preview |
await _pictureController.takePicture('THE_IMAGE_PATH/myimage.jpg');
await _videoController.recordVideo('THE_IMAGE_PATH/myvideo.mp4');
await _videoController.stopRecordingVideo();
The property imagesStreamBuilder allows you to get an imageStream once the camera is ready. Don't try to show all these images on Flutter UI as you won't have time to refresh UI fast enough. (there is too much images/sec).
CameraAwesome(
...
imagesStreamBuilder: (imageStream) {
/// listen for images preview stream
/// you can use it to process AI recognition or anything else...
print('-- init CamerAwesome images stream');
},
)
CamerAwesome was developed to support most devices on the market but some feature can't be fully functional. You can check if your device support all feature by clicking bellow.
Feel free to contribute to improve this compatibility list.
Reveal grid
Devices | Flash | Focus | Zoom | Flip |
---|---|---|---|---|
iPhone 5s | โ | โ | โ | โ |
iPhone X | โ | โ | โ | โ |
iPhone 7 | โ | โ | โ | โ |
iPhone 12 Pro | โ | โ | โ | โ |
iPhone SE (2nd gen) | โ | โ | โ | โ |
One Plus 6T | โ | โ | โ | โ |
Xiaomi redmi | โ | โ | โ | โ |
Honor 7 | โ | โ | โ | โ |
Sony Xperia XZ F8331 | โ | โ | โ | โ |
Pixel 4 | โ | โ | โ | โ |
Galaxy S7 | โ | โ | โ | โ |
LG k50s | โ | โ | โ | โ |
Feel free to help by submitting PR !
- ๐ฅ Record video (partially, iOS only)
- ๐ Focus on specific point
-
๐ก Broadcast live image stream -
๐ค Exposure level -
โ Add e2e tests -
๐ผ Fullscreen/SizedBox support -
๐ฎ Complete example -
๐ Take a picture -
๐ Zoom level -
๐ฒ Live switching camera -
๐ธ Device flash support -
โ๏ธ Auto focus
Initiated and sponsored by Apparence.io.
Contributions are welcome. Contribute by creating a PR or create an issue ๐.