camsnap 0.0.10

Flutter Android iOS

Flutter camera widget.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:camsnap_plugin/camera_view.dart';
import 'package:path_provider/path_provider.dart';
import 'dart:io';

void main() => runApp(MaterialApp(home: CameraViewExample()));

class CameraViewExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    double screenHeight = MediaQuery.of(context).size.height;
    double screenWidth = MediaQuery.of(context).size.width;
    CameraView cam = CameraView(
      onCameraViewCreated: _onCameraViewCreated,
    );

    return Scaffold(
        //appBar: AppBar(title: const Text('Flutter CameraView example')),
        body: Column(children: [
          Center(
              child: Container(
                  width: screenWidth,
                  height: screenHeight,
                  child: cam
              )),
        ]));
  }

  void _onCameraViewCreated(CameraViewController controller) async {
    Directory appDocDir = await getExternalStorageDirectory();
    appDocDir.exists().then((isExists) async {
      if (!isExists) {
        appDocDir = await getApplicationDocumentsDirectory();
      }
    });
    String dir = appDocDir.path + '/Nailsnap/images';
    new Directory(dir).exists().then((isExists) {
      if (!isExists) {
        new Directory(dir).create(recursive: true);
      }
    });
    print(controller.captureImage(dir, 'IMG_' + new DateTime.now().millisecondsSinceEpoch.toString() + '.jpg'));
    print('========================== LOADING');
  }
}
0
likes
70
pub points
8%
popularity

Flutter camera widget.

Homepage

Documentation

API reference

Uploader

invariance.pub@gmail.com

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on camsnap