Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'dart:io';
- import 'package:flutter/material.dart';
- import 'package:image_picker/image_picker.dart';
- void main() => runApp(MyApp());
- class MyApp extends StatefulWidget {
- @override
- State<StatefulWidget> createState() => new _MyAppState();
- }
- class _MyAppState extends State<MyApp>{
- File _image;
- Future getImage() async{
- var image = await ImagePicker.pickImage(source: ImageSource.camera);
- setState(() {
- _image = image;
- });
- }
- @override
- Widget build(BuildContext context) {
- return new MaterialApp(title: "Image Picker",
- home: new Scaffold(
- appBar: new AppBar(title: new Text("Camera Demo"),
- ),
- body: new Center(child: _image == null ? new Text("Sem imagens selecionadas") : new Image.file(_image) ,
- ),
- floatingActionButton: new FloatingActionButton(
- onPressed: getImage ,
- tooltip: "Pick image",
- child: new Icon(Icons.camera),),
- ),);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement