media_picker_builder 1.2.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 86

media_picker_builder #

A flutter plugin that returns multimedia picker data such as folders and its content path list to build your own custom flutter picker

Getting Started #

Please check the provided example for more info.

Alt Text

1.2.3 #

  • Fix crash when generating thumbnail for unsupported photos or videos on Android

1.2.2 #

  • Fix thumbnails not loading on android 10

1.2.1+4 #

  • Use DispatchSemaphore instead of DispatchGroup

1.2.1+3 #

  • Fix path is null on iOS 13 (simulator) because [PHImageFileURLKey] is not provided anymore

1.2.0+2 #

  • Fix crash on android when getting the thumbnail

1.2.0+1 #

  • Cache video duration for fast retrieval on iOS

1.2.0 #

iOS

  • Return video duration with getMediaFile
  • Duration can also be returned with getAlbums if the argument loadIOSPath is true

Android

  • Return video duration and mimeType of files with getMediaFile and getAlbums

1.1.1 #

  • On iOS, fix crash when retrieving albums

1.1.0+1 #

  • Added a new api to get media file based on file id
  • For iOS only, new flag [loadIOSPaths] added to optimize the speed of querying the files.

1.0.0+2 #

  • Remove meta dependency

1.0.0+1 #

  • Update docs

1.0.0 #

  • Initial release

example/README.md

media_picker_builder_example #

Alt Text

Android #

android/app/src/main/manifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
.....
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

iOS #

ios/Runner/info.plist

...
  <key>NSPhotoLibraryUsageDescription</key>
	<string>To upload photos, please allow permission to access your photo library.</string>
...

Full example #

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:media_picker_builder/data/media_file.dart';
import 'package:media_picker_builder/media_picker_builder.dart';
import 'package:media_picker_builder_example/picker/picker_widget.dart';
import 'package:permission_handler/permission_handler.dart';

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

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

class _MyAppState extends State<MyApp> {
  final navigatorKey = GlobalKey<NavigatorState>();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorKey: navigatorKey,
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Picker Demo'),
        ),
        body: Center(
          child: RaisedButton(
            child: const Text("Albums"),
            onPressed: () {
              _checkPermission().then((granted) {
                if (!granted) return;

                // To build your own custom picker use this api
//                MediaPickerBuilder.getAlbums(
//                  withImages: true,
//                  withVideos: true,
//                ).then((albums) {
//                  print(albums);
//                });

                // If you are happy with the example picker then you use this!
                _buildPicker();
              });
            },
          ),
        ),
      ),
    );
  }

  _buildPicker() {
    showModalBottomSheet<Set<MediaFile>>(
      context: navigatorKey.currentState.overlay.context,
      builder: (BuildContext context) {
        return PickerWidget(
          withImages: true,
          withVideos: true,
          onDone: (Set<MediaFile> selectedFiles) {
            print(selectedFiles);
            Navigator.pop(context);
          },
          onCancel: () {
            print("Cancelled");
            Navigator.pop(context);
          },
        );
      },
    );
  }

  Future<bool> _checkPermission() async {
    final permissionStorageGroup =
        Platform.isIOS ? PermissionGroup.photos : PermissionGroup.storage;
    Map<PermissionGroup, PermissionStatus> res =
        await PermissionHandler().requestPermissions([
      permissionStorageGroup,
    ]);
    return res[permissionStorageGroup] == PermissionStatus.granted;
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  media_picker_builder: ^1.2.3

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_builder/media_picker_builder.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
71
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
86
Learn more about scoring.

We analyzed this package on Oct 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test