Check Mobile App
Read now
Start a Project

File Picker In Flutter

Save

In this blog, we will learn and implement file picker in flutter. We are going to use file_picker package from pub.dev. file_picker package is very easy to use to select files from native file explorer, it allows you to use platform native file explorer to select files. It supports single and multiple file selection and also extension filtering to pick the files. File picker allow us to select different types of files like image, video, audio, pdf, document etc.

Implementing file_picker in flutter app:

Create a new flutter project & add flutter picker package

open pubspec.yaml file & add file_picker

Step 1: Create a flutter project & add file_picker dependencies

then run flutter pub get command to download the package into your flutter project.

Step 2: import file_picker.dart:

Once you have added the dependencies package succesfully, to use file_picker you need to import it.

Now, you are ready to easily pick files in flutter app.

Properties of PickFiles:

For Single file: If you want to pick a single file then no need to pass allowMultiple, default value is false for allowMultiple.

For Multiple file: If you want to pick more then one file at once(multiple file picking), you need to use below code.

2. allowedExtensions: : Allow only specific extensions file to be picker.
Eg: allowedExtensions: [‘jpg’, ‘pdf’, ‘png’]

Selected file details:

After picked files using filepicker, you can read the details of file like name of file, size of file, type of file(extensions) and path of selected file.

For select a directory:

Code:


Output:

Here is the output of our file picker flutter simple example.

Conclusion

This is just a simple example of file picker in flutter. You can extend this file picker and customize this as your need.

You can go through the official documentation here for more details.

To read more Mobikul blogs, Please click here.

Thanks for reading…

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

When I think in getting solutions for my Ecommerce Platform, I think of Webkul. They have been such a blessing in our business. We have spent thousands of dollars in support and modules from them. We love their support team. They work very closely with us, and they always go the extra mile when we need help.

Michael Urresta

Michael Urresta

Talk to Sales

Global

Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home