image_picker 0.1.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 50

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),
      ),
    );
  }
}

0.1.0 #

  • Updated dependencies
  • Breaking Change: You need to add a maven section with the "https://maven.google.com" endpoint to the repository section of your android/build.gradle. For example:
allprojects {
    repositories {
        jcenter()
        maven {                              // NEW
            url "https://maven.google.com"   // NEW
        }                                    // NEW
    }
}

0.0.3 #

  • Fix for crash on iPad when showing the Camera/Gallery selection dialog

0.0.2+2 #

  • Updated README

0.0.2+1 #

  • Updated README

0.0.2 #

  • Fix crash when trying to access camera on a device without camera (e.g. the Simulator)

0.0.1 #

  • Initial Release

example/lib/main.dart

// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

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

import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Image Picker Demo',
      home: new MyHomePage(title: 'Image Picker Example'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  Future<File> _imageFile;

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: const Text('Image Picker Example'),
      ),
      body: new Center(
          child: new FutureBuilder<File>(
              future: _imageFile,
              builder: (BuildContext context, AsyncSnapshot<File> snapshot) {
                if (snapshot.connectionState == ConnectionState.done) {
                  return new Image.file(snapshot.data);
                } else {
                  return const Text('You have not yet picked an image.');
                }
              })),
      floatingActionButton: new FloatingActionButton(
        onPressed: () {
          setState(() {
            _imageFile = ImagePicker.pickImage();
          });
        },
        tooltip: 'Pick Image',
        child: new Icon(Icons.add_a_photo),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  image_picker: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:image_picker/image_picker.dart';
  
Version Uploaded Documentation Archive
0.6.0+8 May 23, 2019 Go to the documentation of image_picker 0.6.0+8 Download image_picker 0.6.0+8 archive
0.6.0+7 May 22, 2019 Go to the documentation of image_picker 0.6.0+7 Download image_picker 0.6.0+7 archive
0.6.0+6 May 22, 2019 Go to the documentation of image_picker 0.6.0+6 Download image_picker 0.6.0+6 archive
0.6.0+5 May 22, 2019 Go to the documentation of image_picker 0.6.0+5 Download image_picker 0.6.0+5 archive
0.6.0+4 May 20, 2019 Go to the documentation of image_picker 0.6.0+4 Download image_picker 0.6.0+4 archive
0.6.0+3 May 9, 2019 Go to the documentation of image_picker 0.6.0+3 Download image_picker 0.6.0+3 archive
0.6.0+2 Apr 30, 2019 Go to the documentation of image_picker 0.6.0+2 Download image_picker 0.6.0+2 archive
0.6.0+1 Apr 25, 2019 Go to the documentation of image_picker 0.6.0+1 Download image_picker 0.6.0+1 archive
0.6.0 Apr 25, 2019 Go to the documentation of image_picker 0.6.0 Download image_picker 0.6.0 archive
0.5.4+3 Apr 23, 2019 Go to the documentation of image_picker 0.5.4+3 Download image_picker 0.5.4+3 archive

All 53 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
100
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://dart.dev/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0