uri_to_file 0.1.3
uri_to_file: ^0.1.3 copied to clipboard

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

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: ^0.1.3

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
    Uri uri = Uri.parse(uriString); // Parsing uri string to uri
    File file = await toFile(uri); // Converting uri to file
  } on UnsupportedError catch (e) {
    print(e.message); // Unsupported error for uri not supported
  } on IOException catch (e) {
    print(e); // IOException for system error
  } on Exception catch (e) {
    print(e); // General exception
  }
}

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)

MIT License

Features and bugs #

Please file feature requests and bugs at the issue tracker.

0
likes
120
pub points
68%
popularity

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on uri_to_file