Last updated:
0 purchases
gmo media picker
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"
/>
copied to clipboard
iOS #
Platform version has to be at least 10.0. Modify ios/Podfile and update accordingly.
platform :ios, '10.0'
copied to clipboard
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>
copied to clipboard
install #
Add to pubspec #
dependencies:
gmo_media_picker: 0.0.1
copied to clipboard
Screenshots #
Usage #
import 'package:media_picker/media_picker.dart';
copied to clipboard
MediaPicker.assetPicker(
context,
singleCallback: (AssetEntity asset){
//return selected items
}
);
copied to clipboard
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
},
);
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.