안드로이드, iOS, macOS에서 외부 저장소의 파일을 열고 읽고 쓸 수 있도록 해주는 플러터 플러그인입니다. 기존 파일 조작과 새 파일 생성 모두를 지원하여 지속적인 파일 처리가 필요한 앱에 적합합니다. 플러그인은 표준 파일 선택 기능을 확장하여 수정 후 데이터를 다시 저장할 수 있는 쓰기 기능을 제공합니다. 네이티브 파일 시스템과 원활하게 통합되도록 설계되어 플랫폼 간 일관된 경험을 제공합니다.
사용 사례
오프라인에서 문서 편집하기
사용자 생성 콘텐츠 저장
앱에서 프로젝트 파일 관리하기
앱에서 장치로 데이터 내보내기
구성 파일 저장
크리에이티브 앱에서 미디어 파일 다루기
주요 기능
파일 접근 읽기 및 쓰기
외부 저장소에 새 파일 생성
크로스 플랫폼 지원 (Android, iOS, macOS)
보안 파일 처리
네이티브 파일 선택기와의 통합
지속적인 파일 저장
적합한 대상
생산성 앱
문서 편집기
미디어 관리 도구
데이터 내보내기/가져오기 기능
창의적 응용 프로그램
파일 기반 구성 시스템
고려 사항
적절한 플랫폼 권한이 필요합니다
런타임 권한 요청이 필요할 수 있습니다
파일 경로는 플랫폼에 따라 다릅니다
외부 저장소 접근에 한정
내부 앱 데이터에 적합하지 않음
사용자는 파일 시스템 접근 권한을 부여해야 합니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
file_picker_writable
Flutter plugin to choose files which can be read, referenced and written back at a
later time (persistent permissions on android, secure bookmarks on iOS).
It also offers handlers for open intents when the user wants to open associated files from
other apps. In the same way it will also handle arbitrary URLs and pass them back to dart.
Requirements
iOS
iOS 8 + Swift 5
Only tested on iOS 13+, so let me know ;-)
Support for file handlers
Configure an OTI Type: https://developer.apple.com/library/archive/qa/qa1587/_index.html
Is currently not supported. The only thing the plugin will do is listen for URL Events
and pass them through to the dart side.
Getting Started
See the example on how to implement it in a simple application.
Future<void> readFile() async {
final fileInfo = awaitFilePickerWritable().openFile((fileInfo, file) async {
_logger.fine('Got picker result: $fileInfo');
// now do something useful with the selected file...
_logger.info('Got file contents in temporary file: $file');
_logger.info('fileName: ${fileInfo.fileName}');
_logger.info('Identifier which can be persisted for later retrieval:''${fileInfo.identifier}');
return fileInfo;
});
if (fileInfo == null) {
_logger.info('User canceled.');
return;
}
}
The returned fileInfo.identifier can be used later to write or read from the data,
even after an app restart.
Future<void> persistChanges(FileInfo fileInfo, Uint8List newContent) async {
// tell FilePickerWritable plugin to write the new contents over the user selected fileawaitFilePickerWritable().writeFile(
identifier: fileInfo.identifier,
writer: (file) async {
// write new content into the temporary file.await file.writeBytes(newContent);
});
}
Create a new file by letting the user choose a directory and file name:
final rand = Random().nextInt(10000000);
final fileInfo = awaitFilePickerWritable().openFileForCreate(
fileName: 'newfile.$rand.codeux',
writer: (file) async {
final content = 'File created at ${DateTime.now()}\n\n';
await file.writeAsString(content);
},
);
if (fileInfo == null) {
_logger.info('User canceled.');
return;
}
final data = await _appDataBloc.store.load();
await _appDataBloc.store
.save(data.copyWith(files: data.files + [fileInfo]));
}