Repository navigation
Description
Describe the bug
On iOS, with file_picker 13.1.0 (file_picker_darwin 2.3.1), each file picked with the document picker (FileType.any, FileType.custom or FileType.audio) ends up stored twice in the app's temporary directory: iOS's copy, in tmp/<bundle id>-Inbox/, and file_picker's copy of that, in tmp/<UUID>/. So it takes twice its size there, until iOS clears that directory. For a large video or archive, that can be a lot.
Platform
- Android
- iOS
- Web
- Desktop
Platform OS version
iOS 17.5 (Simulator, iPhone 15 Pro)
How are you picking?
final files = await FilePicker.pickFiles(type: FileType.any);Details to reproduce the issue
- Put an ordinary file (not a package-format document like
.rtfd), such as a PDF, in Files. In the Simulator, drag it onto the Simulator window, and save it under On My iPhone. - Create the repro app, with the
lib/main.dartbelow, and run it:flutter create --platforms=ios copies_repro cd copies_repro flutter pub add file_picker:13.1.0 # Replace lib/main.dart with the file below, then: flutter run
- Tap Pick a file, and pick that file. The app lists every file in its container (the folder above
tmp/) with the same name as the picked file.- Expected: one copy.
- Actual: two: one where iOS put its copy (
tmp/com.example.copiesRepro-Inbox/), and one in file_picker'stmp/<UUID>/.
Repro app: lib/main.dart
import 'dart:io';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(const MaterialApp(home: ReproPage()));
class ReproPage extends StatefulWidget {
const ReproPage({super.key});
@override
State<ReproPage> createState() => _ReproPageState();
}
class _ReproPageState extends State<ReproPage> {
String _log = 'Tap the button, and pick one file from Files.';
// Lists every file in the app's container (the folder above tmp/) with
// the same name as the picked file, with sizes.
String _findCopies(String path) {
final i = path.lastIndexOf('/tmp/');
if (i < 0) return '(path is not under tmp/)';
final root = Directory(path.substring(0, i));
final name = path.split('/').last;
final lines = <String>['Files named $name in the app container:'];
try {
for (final entity in root.listSync(recursive: true)) {
if (entity is! File || entity.path.split('/').last != name) continue;
lines.add(' ${entity.path.substring(root.path.length + 1)}'
' (${entity.lengthSync()} bytes)');
}
} on FileSystemException catch (e) {
lines.add(' (listing failed: $e)');
}
return lines.join('\n');
}
Future<void> _pick() async {
String text;
try {
final files = await FilePicker.pickFiles(type: FileType.any);
text = files.isEmpty
? 'Empty result (as if cancelled).'
: files.map((f) => 'name: ${f.name}\npath: ${f.path}\n\n'
'${f.path == null ? '(no path)' : _findCopies(f.path!)}').join('\n\n');
} on PlatformException catch (e) {
text = 'PlatformException: code ${e.code}, message ${e.message}';
}
debugPrint(text);
setState(() => _log = text);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Document copies repro')),
body: ListView(padding: const EdgeInsets.all(16), children: [
FilledButton(onPressed: _pick, child: const Text('Pick a file')),
const SizedBox(height: 16),
SelectableText(_log),
]));
}
}Error Log
N/A: no error is reported.
Screenshots and/or video
Flutter Version details
Details
$ flutter doctor -v
[!] Flutter (Channel [user-branch], 3.49.0-1.0.pre-314, on macOS 26.5.1 25F80 darwin-arm64, locale en-US) [337ms]
! Flutter version 3.49.0-1.0.pre-314 on channel [user-branch] at /Users/chrisbobbe/.local/lib/flutter
Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
If that doesn't fix the issue, try deleting the 'bin/cache/flutter.version.json' file in your Flutter SDK directory and then
reinstall Flutter by following instructions at https://flutter.dev/setup.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 3611dd5889 (9 days ago), 2026-10-05 23:43:21 +0000
• Engine revision d7fe60992f
• Dart version 3.14.0 (build 3.14.0-294.0.dev)
• DevTools version 2.61.0
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios,
cli-animations, enable-native-assets, enable-record-use, enable-swift-package-manager, omit-legacy-version-file,
enable-lldb-debugging, enable-uiscene-migration, enable-riscv64, enable-hcpp
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform
update checks and upgrades.
[!] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [1,869ms]
• Android SDK at /Users/chrisbobbe/Library/Android/sdk
• Emulator version 36.1.9.0 (build_id 13823996) (CL:N/A)
• Platform android-36, build-tools 36.0.0
• ANDROID_HOME = /Users/chrisbobbe/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.0.10+-117844308-b1163.108)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 26.6) [871ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 17F113
• CocoaPods version 1.17.0
[✓] Chrome - develop for the web [5ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Connected device (4 available) [10.2s]
• Chris’s iPhone (mobile) • <redacted> • ios • iOS 26.6.2 23G90
• iPhone 15 Pro (mobile) • D2E5855E-A059-4FBB-A9AF-117C12378F4F • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-5
(simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 26.5.1 25F80 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 155.0.8059.79
[✓] Network resources [188ms]
• All expected network resources are available.
! Doctor found issues in 2 categories.
Additional context
Claude Code helped me trace this in the source:
The document picker is opened with asCopy: true, so iOS hands the app its own copy of each picked file. Then file_picker passes each one through copyToTemporaryDirectory, which copies it again into a new tmp/<UUID>/ directory.
file_picker 11 opened the picker in import mode, which also gives the app a copy, but then it moved that copy instead of copying it.
Suggestion: for document-picker results, move the file into tmp/<UUID>/ instead of copying it. The app owns iOS's copy, and nothing else uses it. (Photo-picker results still need a copy, since iOS deletes those files when the load callback returns.)
Activity
vicajilau commentedon Oct 15, 2026
Fixed in file_picker_darwin 2.3.2 (#2264), already on pub.dev. The copy iOS hands over is now moved into the plugin's temporary folder instead of being copied again, so each picked document is stored only once. Thanks for spotting this!
Load only what was picked on iOS and stop storing it twice
deps: Upgrade file_picker to 13.1.0, with the packages that requires
deps: Upgrade file_picker to 13.1.0, with the packages that requires
deps: Upgrade file_picker to 13.1.0, with the packages that requires
Unit test the iOS picker loading with mocked items