magiceye 0.1.7+1 copy "magiceye: ^0.1.7+1" to clipboard
magiceye: ^0.1.7+1 copied to clipboard

discontinued

An abstraction on top of flutter camera, that allows you to have a default camera screen or build your own with the layer builders.

example/lib/main.dart

import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:magiceye/magiceye.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  SystemChrome.setPreferredOrientations(
    [DeviceOrientation.portraitUp],
  ).then(
    (_) => runApp(MyApp()),
  );
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('MagicEye'),
        ),
        body: Center(
          child: LoucoButton(),
        ),
      ),
    );
  }
}

class LoucoButton extends StatelessWidget {
  final StreamController<File> file = StreamController.broadcast();

  LoucoButton({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          children: <Widget>[
            RaisedButton(
              child: Text("Take Picture"),
              onPressed: () => MagicEye().push(context).then(
                    (path) => path?.fold(
                      (e) => print("Error :: ${e.message}"),
                      (path) => file.add(
                        File(path),
                      ),
                    ),
                  ),
            ),
            SizedBox(height: 16),
            StreamBuilder<File>(
              stream: file.stream,
              initialData: null,
              builder: (context, snapshot) => snapshot.hasData
                  ? Image.file(snapshot.data)
                  : AspectRatio(
                      aspectRatio: 9 / 16,
                      child: Container(color: Colors.grey[300]),
                    ),
            ),
          ],
        ),
      ),
    );
  }
}
19
likes
40
pub points
0%
popularity

Publisher

unverified uploader

An abstraction on top of flutter camera, that allows you to have a default camera screen or build your own with the layer builders.

Repository (GitHub)
View/report issues

License

GPL-3.0 (LICENSE)

Dependencies

camera, dartz, flutter, native_device_orientation, path_provider, rxdart

More

Packages that depend on magiceye