picker_pro_max_ultra 2.0.10 copy "picker_pro_max_ultra: ^2.0.10" to clipboard
picker_pro_max_ultra: ^2.0.10 copied to clipboard

Advanced media picker for Flutter with support for images, videos, camera capture, documents, and multi-selection.

example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:picker_pro_max_ultra/media_picker_widget.dart';

void main() async{
  WidgetsFlutterBinding.ensureInitialized();
  await SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitUp,
    DeviceOrientation.portraitDown,
  ]);
  runApp(MyApp());
}


class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);



  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Media Picker',
      theme: ThemeData(
        primarySwatch: Colors.green,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  String filePath = "";
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Image picker demo'),
      ),
      body: Column(
        children: [
          Center(child: Text("Picked or Captured file path is $filePath")),
          //if(filePath.isNotEmpty && !kIsWeb) Image.file(File(filePath),height: 400,width: double.infinity,),
          if(filePath.isNotEmpty && kIsWeb) Image.network(filePath,height: 400,width: double.infinity,)
        ],
      ),
      floatingActionButton: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        spacing: 10,
        children: [
          FloatingActionButton(
            child: const Icon(Icons.filter),
            onPressed: () async {

              /// show loader
              MediaPicker(
                      context: context,
                      maxLimit: 5 ?? 1,
                      cancelText: "No",
                      doneText: "Yes",
                      mediaType: MediaType.image
              )
                  .showPicker()
                  .then((file) {

                    print("file");
                    print(file);
                /// hide loader
                if (file.isNotEmpty) {
                  filePath = file.first;
                  setState(() {});
                }
              }).catchError((onError) {
                /// hide loader
              });
            },
          ),
          FloatingActionButton(
            child: const Icon(Icons.video_call_sharp),
            onPressed: () async {
              /// show loader
              MediaPicker(
                      context: context,
                      maxLimit: 5 ?? 1,
                      cancelText: "No",
                      doneText: "Yes",
                      mediaType: MediaType.video
              )
                  .showPicker()
                  .then((file) {
                /// hide loader
                if (file.isNotEmpty) {
                  filePath = file.first;
                  setState(() {});
                }
              }).catchError((onError) {
                /// hide loader
              });
            },
          ),
          FloatingActionButton(
            child: const Icon(Icons.file_copy),
            onPressed: () async {
              MediaPicker(
                context: context,
                mediaType: MediaType.audio
              ).picFile().then((file) {
                /// hide loader
                if (file != null) {
                  filePath = file.path;
                  setState(() {});
                }
              }).catchError((onError) {
                /// hide loader
              });
            },
          ),
          FloatingActionButton(
            child: const Icon(Icons.camera),
            onPressed: () async {
             MediaPicker(
                context: context,
              ).capturedFile(allowRecord: false).then((file) {
               /// hide loader
               if (file != null) {
                 filePath = file.path;
                 setState(() {});
               }
             }).catchError((onError) {
               /// hide loader
             });
            },
          ),
          FloatingActionButton(
            child: const Icon(Icons.music_note),
            onPressed: () async {
              /// show loader
              MediaPicker(
                  context: context,
                  maxLimit: 5 ?? 1,
                  mediaType: MediaType.audio
              )
                  .showPicker()
                  .then((file) {
                /// hide loader
                if (file.isNotEmpty) {
                  filePath = file.first;
                  setState(() {});
                }
              }).catchError((onError) {
                /// hide loader
              });
            },
          ),
        ],
      ),
    );
  }
}
4
likes
150
points
136
downloads

Publisher

unverified uploader

Weekly Downloads

Advanced media picker for Flutter with support for images, videos, camera capture, documents, and multi-selection.

Homepage
Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

camera, flutter, flutter_web_plugins, path_provider, photo_manager, plugin_platform_interface, web

More

Packages that depend on picker_pro_max_ultra