gmo_media_picker 0.0.4 copy "gmo_media_picker: ^0.0.4" to clipboard
gmo_media_picker: ^0.0.4 copied to clipboard

An audio/video/image picker in pure Dart, support multi picking.

gmo_media_picker #

Flutter plugin to get pictures, videos and audios. 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, videos and audios if you wish

Requirements #

Android #

Kotlin and Gradle version

  • Upgrade your Gradle version (the one in gradle-wrapper.properties) to 6.8.3 or the latest version but lower than 7.0.0.
  • Upgrade your Kotlin version (ext.kotlin_version) to 1.4.32 or the latest version.
  • Required permissions: INTERNET, READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE, ACCESS_MEDIA_LOCATION. If you don't need the ACCESS_MEDIA_LOCATION permission,
<uses-permission
  android:name="android.permission.ACCESS_MEDIA_LOCATION"
  tools:node="remove"
  />

iOS #

  1. Platform version has to be at least 10.0. Modify ios/Podfile and update accordingly.
platform :ios, '10.0'
  1. Add the following content to info.plist.
<key>NSAppTransportSecurity</key>
<dict>
	<key>NSAllowsArbitraryLoads</key>
	<true/>
</dict>
<key>NSPhotoLibraryUsageDescription</key>
<string>Replace with your permission description.</string>

install #

Add to pubspec #

dependencies:
  gmo_media_picker: 0.0.1

Screenshots #

1 2 3

Usage #

import 'package:media_picker/media_picker.dart';
 MediaPicker.assetPicker(
      context,
      singleCallback: (AssetEntity asset){
        //return selected items
      }
  );
Parameter Type Description Default
isMulti bool Multiple select mode false
type RequestType Request type for picker RequestType.common
limit int Maximum asset that the picker can pick 10
isReview bool Review before select true
filterOptions FilterOptionGroup? Allow users to customize assets filter options null
leadingBuilder WidgetBuilder? The widget builder for the special item null
routeDuration Duration The duration which the picker use to build page route transition const Duration(milliseconds: 300)
mulCallback MulCallback? Return list item in select null
singleCallback SingleCallback? Return item in select null

Example #


import 'package:gmo_media_picker/media_picker.dart';

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);
  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  bool isReview = false;
  bool isMulti = false;
  @override
  Widget build(BuildContext context) {
    final themeData = Theme.of(context);
    return Scaffold(
      appBar: AppBar(
        title:const  Text('Media picker example'),
      ),
      body: SafeArea(
        child: SizedBox(
          width: double.infinity,
          height: double.infinity,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  const Text("Review"),
                  Switch(
                    value: isReview,
                    onChanged: (newValue) {
                      setState(() => isReview = newValue);
                    },
                  ),
                ],
              ),
              const SizedBox(height: 10),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  const Text("Multi Mode"),
                  Switch(
                    value: isMulti,
                    onChanged: (newValue) {
                      setState(() => isMulti = newValue);
                    },
                  ),
                ],
              ),
              MaterialButton(
                color: themeData.primaryColor,
                child: const Text(
                  'All',
                  style: TextStyle(color: Colors.white),
                ),
                onPressed: () {
                  picker(RequestType.all);
                },
              ),
              MaterialButton(
                color: themeData.primaryColor,
                child: const Text(
                  'Images and videos',
                  style: TextStyle(color: Colors.white),
                ),
                onPressed: () {
                  picker(RequestType.common);
                },
              ),
              MaterialButton(
                color: themeData.primaryColor,
                child: const Text(
                  'Image picker',
                  style: TextStyle(color: Colors.white),
                ),
                onPressed: () {
                  picker(RequestType.image);
                },
              ),
              MaterialButton(
                color: themeData.primaryColor,
                child: const Text(
                  'Video picker',
                  style: TextStyle(color: Colors.white),
                ),
                onPressed: () {
                  picker(RequestType.video);
                },
              ),
              MaterialButton(
                color: themeData.primaryColor,
                child: const Text(
                  'Audio picker',
                  style: TextStyle(color: Colors.white),
                ),
                onPressed: () {
                  picker(RequestType.audio);
                },
              ),
            ],
          ),
        ),
      ),
    );
  }

  void picker(RequestType type) {
    MediaPicker.picker(
      context,
      isMulti: isMulti,
      type: type,
      isReview: isReview,
      mulCallback: (List<AssetEntity> assets) {
        //return list if isMulti true
      },
      singleCallback: (AssetEntity asset) {
        //return single item if  isMulti false
      },
    );
  }
}

8
likes
70
pub points
30%
popularity

Publisher

unverified uploader

An audio/video/image picker in pure Dart, support multi picking.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

extended_image, flutter, photo_manager, video_player

More

Packages that depend on gmo_media_picker