media_picker 1.3.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 85

media_picker #

Flutter plugin to get pictures and videos. It allows you to select one or more images from gallery or camera, without needing to switch provider. It also allows you to select both images and videos if you wish

Getting Started #

For help getting started with Flutter, view our online documentation.

This Plugin is under development. It works in IOS and Android

Forked from Flutter Medias Picker

For help on editing plugin code, view the documentation.

In order to load the images requested in Flutter's Image, you need to use the flutter_absolute_path plugin

check the included example if you need to see how to use it. (You'll need to raise your minSdkVersion to 19)

You need to add these styles to Android to use the plugin

or else keep using version 1.3.2

  <style name="LibAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
      <!-- Customize your theme here. -->
      <item name="colorPrimary">@color/colorPrimary</item>
      <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
      <item name="colorAccent">@color/colorAccent</item>
      <item name="android:colorBackground">@android:color/background_light</item>
      <item name="android:windowBackground">@android:color/white</item>
  </style>

  <style name="PickerTabLayout" parent="Widget.Design.TabLayout">
      <item name="tabBackground">@color/colorPrimary</item>
      <item name="tabGravity">fill</item>
      <item name="tabMaxWidth">0dp</item>
  </style>

  <style name="SmoothCheckBoxStyle">
      <item name="color_checked">@color/checkbox_color</item>
      <item name="color_unchecked">@android:color/white</item>
      <item name="color_unchecked_stroke">@color/checkbox_unchecked_color</item>
      <item name="color_tick">@android:color/white</item>
  </style>

in manifest:

add <uses-permission android:name="android.permission.CAMERA"/> in proguard-rules.pro add:

# Glide
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep class * extends com.bumptech.glide.module.AppGlideModule {
 <init>(...);
}
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}
-keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder {
  *** rewind();
}

# Uncomment for DexGuard only
#-keepresourcexmlelements manifest/application/meta-data@value=GlideModule

and in your podfile

platform :ios, '9.0'
use_frameworks!

[1.3.5] - 2020.07.02 #

  • fix iOS build

[1.3.4] - 2020.07.01 #

  • added support for not showing camera option

[1.3.3] - 2020.05.28 #

  • updated Android picker dependency

[1.3.2] - 2020.05.13 #

  • added preventive Flutter result null check
  • update android dependencies
  • update gradle

[1.3.1] - 2020.01.24 #

  • merge pull request from Miguel Ruivo @miguelpruivo to fix Android image compression

[1.3.0] - 2019.10.04 #

  • merge pull request from Miguel Ruivo @miguelpruivo to fix iOS 13 not working
  • merge pull request from Askar Syzdykov @askarsyzdykov to cleanup some code

[1.2.3] - 2019.10.01 #

  • updates example README

[1.2.2] - 2019.10.01 #

  • updates with upstream medias_picker

[1.1.2] - 2019.07.01 #

  • gallery with Camera support
  • gallery with video support
  • androidX update
  • Oficializing fork from upstream Flutter Medias Picker

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_absolute_path/flutter_absolute_path.dart';
import 'package:media_picker/media_picker.dart';

void main() => runApp(new MyApp());

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

class _MyAppState extends State<MyApp> {
  String _media = '';
  List<dynamic> _mediaPaths;

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

  pickImages({quantity = 1}) async {
    try {
      _mediaPaths = await MediaPicker.pickImages(withVideo: true, quantity: quantity);

//      filter only images from mediaPaths and send them to the compressor
//      List<dynamic> listCompressed = await MediasPicker.compressImages(imgPaths: [firstPath], maxWidth: 600, maxHeight: 600, quality: 100);
//      print(listCompressed);

    } on PlatformException {}

    if (!mounted) return;

    convertPath(_mediaPaths.first.toString());
  }

  convertPath(String uri) async {
    final filePath = await FlutterAbsolutePath.getAbsolutePath(uri);
    setState(() {
      _media = filePath;
    });
  }

  pickVideos() async {
    try {
      _mediaPaths = await MediaPicker.pickVideos(quantity: 7);
    } on PlatformException {}

    if (!mounted) return;

    setState(() {
      _media = _mediaPaths.toString();
    });
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Plugin example app'),
        ),
        body: new Center(
          child: new Column(
            children: [
              Image.file(File.fromUri(Uri.parse(_media))),
              new Text('media: $_media\n'),
              new MaterialButton(
                child: new Text(
                  "Pick images and videos",
                ),
                onPressed: () => pickImages(),
              ),
              new MaterialButton(
                child: new Text(
                  "Pick just videos",
                ),
                onPressed: () => pickVideos(),
              ),
              new MaterialButton(
                child: new Text(
                  "Delete temp folder (automatic on ios)",
                ),
                onPressed: () async {
                  if (await MediaPicker.deleteAllTempFiles()) {
                    setState(() {
                      _media = "deleted";
                    });
                  } else {
                    setState(() {
                      _media = "not deleted";
                    });
                  }
                },
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  media_picker: ^1.3.5

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support 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:media_picker/media_picker.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
70
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
85
Learn more about scoring.

We analyzed this package on Jul 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because:

  • package:media_picker/media_picker.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

  • package:media_picker/media_picker.dart that declares support for platforms: android, ios

Package does not support Flutter platform web

Because:

  • package:media_picker/media_picker.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because:

  • package:media_picker/media_picker.dart that declares support for platforms: android, ios

Package not compatible with SDK dart

Because:

  • media_picker that is a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

9 out of 9 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/media_picker.dart.

Run flutter format to format lib/media_picker.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety