Flutter plugin to add Camera support inside your project.
CamerAwesome include a lot of useful features like:
ios/Runner/Info.plist
file<key>NSCameraUsageDescription</key>
<string>Your own description</string>
Android
<application>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
android/app/build.gradle
minSdkVersion 21
import 'package:camerawesome/camerawesome_plugin.dart';
ValueNotifier is a usefull 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<Size> _photoSize = ValueNotifier(null);
// Controller
PictureController _pictureController = new PictureController();
// [...]
}
If you want to change a config, all you need is setting the value. CameraAwesome will handle the rest.
Example:
_switchFlash.value = CameraFlashes.AUTO
// [...]
@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,
orientation: DeviceOrientation.portraitUp,
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 | |
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 | |
orientation | DeviceOrientation |
initial orientation | |
fitted | bool |
whether camera preview must be as big as it needs or cropped to fill with. false by default |
await _pictureController.takePicture('THE_IMAGE_PATH/myimage.jpg');
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 X | โ | โ | โ | โ |
iPhone 7 | โ | โ | โ | โ |
One Plus 6T | โ | โ | โ | โ |
Xiaomi redmi | โ | โ | โ | โ |
Honor 7 | โ | โ | โ | โ |
Feel free to help by submitting PR !
Initiated and sponsored by Apparence.io.
Contributions are welcome. Contribute by creating a PR or create an issue ๐.
Author: Apparence-io
Source Code: https://github.com/Apparence-io/camera_awesome
#flutter #dart #mobile-apps