Migration to Flutter Guide
Discover our battle-tested 21-step framework for a smooth and successful migration to Flutter!
Home
Glossary

File picker in Flutter

What is a file picker in Flutter?

File picking in Flutter app development allows users to select files from device storage such as PDFs, images, or documents. It is commonly used for uploads, attachments, and document handling features.

Flutter does not provide a built-in file picker, so this functionality is handled through plugins that integrate with native file systems.

How does it work?

A file picker opens the system file selection UI and returns metadata about the selected file. Depending on the platform, this may include file name, size, path, or access to the file content.

On mobile platforms, file access is mediated by the operating system. On Flutter Web, files are provided by the browser and do not expose real file paths.

The most widely used solution is the file_picker package.

It supports:

  • Android, iOS, Web, and desktop
  • single and multiple file selection
  • file type filtering
  • access to file metadata and content

For most Flutter apps, it covers all common file selection needs.

File picker example in Flutter

A minimal, production-safe example:

final result = await FilePicker.platform.pickFiles(
  type: FileType.custom,
  allowedExtensions: ['pdf', 'jpg', 'png'],
);

if (result == null) {
  return;
}

final file = result.files.first;

// Mobile / desktop: access via path
if (file.path != null) {
  final fileOnDisk = File(file.path!);
}

// Web or large files: avoid loading full bytes into memory
final stream = file.readStream;

For large files, reading data as a stream is recommended instead of using file.bytes, which loads the entire file into memory.

Handling large files safely

Using file.bytes for large files can cause memory issues, especially on low-end devices.

Best practices:

  • Use readStream for uploads.
  • Process data in chunks.
  • Avoid loading entire files into RAM.

This is especially important for videos, PDFs, and multi-megabyte files.

File picker permissions in Flutter

On iOS, file permissions are handled automatically by the system file picker. No additional configuration is required in most cases.

On Android, modern versions of file_picker use the system file picker intent, which usually does not require manual storage permissions.

However, if your app needs access to files outside standard locations or requires persistent access to external storage, you may still need to:

  • Verify storage-related permissions in AndroidManifest.xml.
  • Test behavior on different Android versions and OEM devices.

In practice, file_picker works without extra permissions in most scenarios, but it is still worth validating this when working with external storage. On Flutter Web, permissions are entirely controlled by the browser.

File picker on Flutter Web

Flutter Web behaves differently than mobile:

  • file.path is usually null.
  • Files must be handled via streams or bytes.
  • Large files require careful memory handling.

Sharing the same file logic across platforms without checks often leads to issues.

Common mistakes with file picker in Flutter

Typical beginner issues include:

  • Loading large files using bytes.
  • Assuming file paths exist on all platforms.
  • Ignoring the cancel case.
  • Reusing mobile file logic on web.
  • Not testing storage access on Android devices.

Most file picker bugs appear during file processing, not during selection.

Learn more

Limiting a Video Upload to a Specific Time Frame

How to Limit a Video Upload to a Specific Time Frame?

One of the projects we delivered at LeanCode was building an application for Healthcare Industry - Quittercheck. While developing the app, the problem we faced was how to limit a video upload to a specific time frame. Read about our tailored solution to this challenge.

Flutter open source packages by LeanCode

6 Non-obvious Flutter and Dart Packages

Almost every production-grade app depends on tens of packages. Using them allows for quick implementation of standard functionalities. Take a closer look at 6 useful but not-so-popular Dart and Flutter packages made and tested by LeanCode's devs.

Flutter architecture by LeanCode

Feature-Based Flutter App Architecture - LeanCode

Read about the LeanCode approach to Flutter architecture. We highlight some of the design decisions that should be made when developing a feature in mobile apps. This includes our approach to dependency injection, state management, widget lifecycle, and data fetching.