Search packages, repositories and app categories

uri_to_file cover
Package detailsv1.0.0

uri_to_file

A Flutter plugin for converting supported uri to file. Supports Android & iOS.

AndroidiOS
30-day downloads
5.2K
Likes
44
Pub points
160

Install package

flutter pub add uri_to_file

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Flutter plugin that converts supported URIs to File objects on Android and iOS. It enables developers to access files from various URI sources, such as images or documents, by transforming them into usable File instances. This is particularly useful when working with file pickers, camera captures, or external file references. The plugin simplifies file handling in cross-platform apps by abstracting platform-specific logic.

Use cases

  • Converting image URIs from gallery to File
  • Handling document file paths from external sources
  • Processing captured media from camera
  • Reading files from shared storage
  • Integrating with file picker plugins
  • Supporting file uploads from URIs

Key features

  • Cross-platform support for Android and iOS
  • Simple URI-to-File conversion
  • Handles common file types
  • Minimal setup required
  • Works with native file system access
  • Compatible with file picker integrations

Suitable for

  • Apps needing file access from URIs
  • Media processing workflows
  • File upload features
  • Image and document handling
  • Developers using file pickers or camera

Considerations

  • Only supports Android and iOS
  • Requires proper permissions for file access
  • Limited to supported URI schemes
  • May not work with all custom or encrypted URIs
  • Depends on underlying platform implementations

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

uri_to_file

Pub

A Flutter plugin for converting supported uri to file. Supports Android & iOS.

Supported Uri Schema

  • content:// (Android Only)
  • Schema supported by File.fromUri(uri)

Get started

Add dependency
dependencies:
  uri_to_file: ^1.0.0
Super simple to use
import 'dart:io';

import 'package:uri_to_file/uri_to_file.dart';

Future<void> convertUriToFile() async {
  try {
    String uriString = 'content://sample.txt'; // Uri string

    // Don't pass uri parameter using [Uri] object via uri.toString().
    // Because uri.toString() changes the string to lowercase which causes this package to misbehave

    // If you are using uni_links package for deep linking purpose.
    // Pass the uri string using getInitialLink() or linkStream

    File file = await toFile(uriString); // Converting uri to file
  } catch (e) {
    print(e); // Exception
  }
}
Important note
  • Don't pass uri parameter using [Uri] object via uri.toString(). Because uri.toString() changes the string to lowercase which causes this package to misbehave
  • If you are using uni_links package for deep linking purpose. Pass the uri string using getInitialLink() or linkStream
  • Check out the full example: https://pub.dev/packages/uri_to_file/example
Working example

Working example

Background
  • content:// (Android Only) uri_to_file creates a temporary file using the content:// uri with the help of native channel that stores this file in the application directory.

  • All the others uri are handled by flutter sdk itself with the help of File.fromUri(uri)

Copyright & License

MIT License

Features and bugs

Please file feature requests and bugs at the issue tracker.

Categories

Dependencies

Dependency list 1 items

  • plugin_platform_interface^2.0.2

Source repository

Projects using this package