magiceye 0.1.7+1 magiceye: ^0.1.7+1 copied to clipboard
An abstraction on top of flutter camera, that allows you to have a default camera screen or build your own with the layer builders.
An abstraction on top of flutter camera.
- Provides the lower level handling of the camera plugin
- Handles all camera resources
- Handle camera status when app activity change
- Can be used out-of-the-box by simply calling
- Can be customized with layers
- Come with a few, pre-baked, preview layers
- Has a functional API leveraged by dartz
Version compatibility #
- Dart: 2.7.0
- Flutter: 1.12.13+hotfix.5 (stable)
See CHANGELOG.md for all breaking (and non-breaking) changes.
Getting started #
magiceye as a dependency in your project:
dependencies: magiceye: ^0.1.7
After this, you should then run
flutter packages upgrade or update your packages with your IDE/editor funcionalities.
If you want to use MagicEye default camera widget, you can do this by calling
Future<Either<MagicEyeException, String>> result = await MagicEye().push(context); result.fold( (exception) => // Handle exception case (path) => // Handle success case. [path] has the path to the file saved );
Disclaimer: MagicEye widget can be used with
Navigator.pushinstead. However, the disposal of resources won't be handled automatically. Use with caution.
You can customize some functionality of the camera passing parameters to the
MagicEye constructor. For detailed info, consult its page on the documentation.
Although MagicEye may be used as is, you can customize it's
previewLayer. Both receives the necessary context and expects to return a
You can see examples of custom layers in the source:
In the near future, more and simpler examples will be provided in the example.
Preview Layer #
The Preview Layer is, usually, used for graphical-only widgets, although it accepts any
Widget. The canvas is limited to the preview area, so if the preview aspect ratio is different from the device's aspect ratio, the canvas will not include the black area.
To make a custom preview layer,
previewLayer accepts a
Widget Function(BuildContext, PreviewLayerContext).
PreviewLayerContext provides the
allowedDirections parameter used on MagicEye instatiation. Also, a
direction stream emits info about the current device orientation.
Control Layer #
The Control Layer is used to render the controls of the camera. Its canvas is the entire device screen. The parameter
controlLayer is similar to
previewLayer, but provides a
ControlLayerContext instead, which gives you access to the camera functions like
For bugs or additional info, feel free to open an issue.