Skip to content

Latest commit

 

History

History
135 lines (104 loc) · 3.53 KB

README.md

File metadata and controls

135 lines (104 loc) · 3.53 KB

Medias Picker

pub package

A Flutter plugin for IOS and Android providing a simple way to get multiple pictures and videos.

Features:

  • Get multiple pictures and videos.
  • Compress images.

Installation

First, add medias_picker as a dependency in your pubspec.yaml file.

Android

You need to add these styles to the android app (app/src/main/values/styles.xml).

  <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>

And need to add the camera permisson. (android/app/src/main/AndroidManifest.xml).

<uses-permission android:name="android.permission.CAMERA"/>

iOS

Set the minimum version to 9.0 and add if not exists one row to the ios/podfile after target runner:

platform :ios, '9.0'

...

target 'Runner' do
    use_frameworks!

...

Example

Here is an example flutter app displaying how to use the MediasPicker.

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:medias_picker/medias_picker.dart';

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

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

class _MyAppState extends State<MyApp> {
  List<String> mediaPaths;

  void _getImages() async {
    mediaPaths = await MediasPicker.pickImages(
      quantity: 7,
      maxWidth: 1024,
      maxHeight: 1024,
      quality: 85,
    );

    if (!mounted) return;
    setState(() {});
  }
  
  void _getVideos() async {
      mediaPaths = await MediasPicker.pickVideos(quantity: 7);
  
      if (!mounted) return;
      setState(() {});
    }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              FlatButton(
                child: Text('Get images'),
                onPressed: _getImages,
              ),
              FlatButton(
                child: Text('Get videos'),
                onPressed: _getVideos,
              ),
              if (mediaPaths != null)
                Text(mediaPaths.join('\n'))
            ],
          ),
        ),
      ),
    );
  }
}

Feedback welcome and Pull Requests are most welcome!