FLUTTER ECOSYSTEM

Nikhil1999/uri-to-file

URI를 파일로 변환하는 Flutter 플러그인입니다.

uri-to-file 프로젝트 이미지
Stars
9
Forks
58
최근 푸시(UTC)
2024. 7. 2.
프로젝트 상태
활성
Nikhil Koshty GitHub avatar
GITHUB User

Nikhil Koshty ↗

언어JavaDart

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 4 개
  • flutter{"sdk":"flutter"}
  • plugin_platform_interface^2.0.2
  • flutter_test개발 의존성{"sdk":"flutter"}
  • flutter_lints개발 의존성^2.0.0

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

README 펼치기 / 접기

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.