Code Monkey home page Code Monkey logo

magiceye's Introduction

MagicEye

An abstraction on top of flutter camera.

Version Build License

Features

  • 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 MagicEye().push(context)
  • 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

Add 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.

Finally, follow the camera installations instructions for iOS and Android.

Usage

If you want to use MagicEye default camera widget, you can do this by calling MagicEye.push:

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.push instead. 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.

Layers

Although MagicEye may be used as is, you can customize it's controlLayer and previewLayer. Both receives the necessary context and expects to return a Widget.

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.

MagicEye provide some default preview layers through PreviewLayer. An example is PreviewLayer.grid, which shows a grid on the preview to help with the Rule of Thirds.

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 takePicture.


For bugs or additional info, feel free to open an issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.