uri_to_file

Pub

A Flutter plugin for converting uri to file. Supports Android.

Supported Uri Schema

  1. content://

Get started

Add dependency

dependencies:
  uri_to_file: ^0.1.2

Super simple to use

import 'dart:io';

import 'package:flutter/services.dart';
import 'package:uri_to_file/uri_to_file.dart';

void getFile() async {
  try {
    String uri = 'content://sample.txt';
    File file = await UriToFile.toFile(uri);
  } on PlatformException catch (e) {
    switch (e.code) {
      case UriToFile.URI_NOT_SUPPORTED:
        {
          print(e.message); // For uri not supported
          break;
        }
      case UriToFile.IO_EXCEPTION:
        {
          print(e.message); // For IO exception
          break;
        }
      default:
        {
          print(e.message); // For default exception
          break;
        }
    }
  } on Exception catch (e) {
    print(e); // For default exception
  }
}

Working example

Working example

MIT License

Features and bugs

Please file feature requests and bugs at the issue tracker.

Libraries

uri_to_file