image_picker 0.1.0 copy "image_picker: ^0.1.0" to clipboard
image_picker: ^0.1.0 copied to clipboard

outdatedDart 1 only

Flutter plugin that shows an image picker.

Image Picker plugin for Flutter #

pub package

A Flutter wrapper for the native image picker.

This enables picking images from the image library, or to take new pictures with the camera.

Note: This plugin is still under development, and some APIs might not be available yet. Feedback welcome and Pull Requests are most welcome!

Usage #

To use this plugin, add image_picker as a dependency in your pubspec.yaml file.

Next, to make the app build for android, open the file android/build.gradle, and add the jitpack.io line shown below:

allprojects {
   repositories {
       jcenter()
       maven { url "https://jitpack.io" }    // Enable getting dependencies from jitpack.io.
   }
}

Example #

class _MyHomePageState extends State<MyHomePage> {
  File imageFile;

  getImage() async {
    var _fileName = await ImagePicker.pickImage();
    setState(() {
      imageFile = _fileName;
    });
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('Image Picker Example'),
      ),
      body: new Center(
        child: imageFile == null
            ? new Text('No image selected.')
            : new Image.file(imageFile),
      ),
      floatingActionButton: new FloatingActionButton(
        onPressed: getImage,
        tooltip: 'Pick Image',
        child: new Icon(Icons.add_a_photo),
      ),
    );
  }
}