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.
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:
For most Flutter apps, it covers all common file selection needs.
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.
Using file.bytes for large files can cause memory issues, especially on low-end devices.
Best practices:
readStream for uploads.This is especially important for videos, PDFs, and multi-megabyte files.
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:
AndroidManifest.xml.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.
Flutter Web behaves differently than mobile:
file.path is usually null.Sharing the same file logic across platforms without checks often leads to issues.
Typical beginner issues include:
bytes.Most file picker bugs appear during file processing, not during selection.
8 min. • Aug 8, 2022
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.
8 min. • Nov 8, 2022
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.
12 min • Jul 27, 2023
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.