flutter_camera_falcon 0.0.5 copy "flutter_camera_falcon: ^0.0.5" to clipboard
flutter_camera_falcon: ^0.0.5 copied to clipboard

The design goal of JSON is to be as simple as possible and be universally usable. This has reduced the readability of the data, to some extent. In contrast, the design goal of YAML is to provide a goo [...]

example/lib/main.dart

import 'dart:developer';
import 'dart:io';

import 'package:flutter/material.dart';

import 'package:flutter/services.dart';
import 'package:flutter_camera_falcon/flutter_camera_falcon.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _imageUri="";
  @override
  void initState() {
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Camera'),
        ),
        body: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children:[
              _imageUri==""?
              const SizedBox.shrink():
                  SizedBox(
                    height: 200,
                    width: 200,
                    child: Image.file(File(_imageUri),fit: BoxFit.fill,),
                  ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  ElevatedButton(onPressed:_getImageFromGallery ,child:const Text("Device"),),
                  ElevatedButton(onPressed: _getImageFromCamera,child:const Text("Camera"),),
                ],
              )],
          ),
        )
      ),
    );
  }
  void _getImageFromGallery() async {
    String? imageUri;
    try {
      imageUri = await FlutterCameraFalcon.getImageFromGallery;
    } on PlatformException catch (platEx) {
      log("_getImageFromGallery/PlatformException  $platEx");
    } catch (ex) {
      log("_getImageFromGallery/Exception  $ex");
    }
    setState(() {
      _imageUri = imageUri??"";
    });
  }
  void _getImageFromCamera() async {
    String? imageUri;
    try {
      imageUri = await FlutterCameraFalcon.getImageFromCamera;
    } on PlatformException catch (platEx) {
      log("_takeImageFromCamera/PlatformException  $platEx");
    } catch (ex) {
      log("_takeImageFromCamera/Exception $ex");
    }
    setState(() {
      _imageUri = imageUri??"";
    });
  }

}
1
likes
110
pub points
0%
popularity

Publisher

unverified uploader

The design goal of JSON is to be as simple as possible and be universally usable. This has reduced the readability of the data, to some extent. In contrast, the design goal of YAML is to provide a good human-readable format and provide support for serializing arbitrary native data structures. This has increased the readability of the YAML files, but it has made the parsing and generation of files somewhat complex. We can see this clearly in the YAML official website where it shows the content in YAML format

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_camera_falcon