images_picker 0.0.5
images_picker: ^0.0.5

Flutter Android iOS

Flutter plugin for selecting images/videos from the Android and iOS image library, and taking pictures/videos with the camera.

example/lib/main.dart

import 'dart:io';

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

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

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  String path;

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          children: [
            Text('Running on: $_platformVersion\n'),
            RaisedButton(
              child: Text('pick'),
              onPressed: ()async {
                List<Media> res = await ImagesPicker.pick(
                  count: 1,
                  // pickType: PickType.video,
                  cropOpt: CropOption(
                    aspectRatio: CropAspectRatio.wh16x9
                  ),
                );
                if (res!=null) {
                  print(res[0]?.path);
                  setState(() {
                    path = res[0]?.thumbPath;
                  });
                }
              },
            ),
            RaisedButton(
              child: Text('openCamera'),
              onPressed: ()async {
                List<Media> res = await ImagesPicker.openCamera(
                  // pickType: PickType.video,
                );
                if (res!=null) {
                  print(res[0]?.path);
                 setState(() {
                   path = res[0]?.path;
                 });
                }
              },
            ),
            path!=null?Container(
              height: 200,
              child: Image.file(
                File(path),
                fit: BoxFit.contain,
              ),
            ):SizedBox.shrink(),
          ],
        ),
      ),
    );
  }
}
8
likes
80
pub points
78%
popularity

Publisher

chavesgu.com

Flutter plugin for selecting images/videos from the Android and iOS image library, and taking pictures/videos with the camera.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on images_picker