Skip to content

iOS: picking a package-format document (such as an .rtfd) returns an image from inside it #2259

Closed

Description

@chrisbobbe

Describe the bug

A package-format document is a folder that macOS and iOS show as a single file, such as a TextEdit .rtfd (rich text with attachments). On iOS, with file_picker 13.1.0 (file_picker_darwin 2.3.1), picking one with the document picker doesn't return the document. Instead, pickFiles returns the first image file found at the package's top level, as if the user had picked that image. If the package contains no image, the document is dropped. (If that leaves nothing, the pick fails with load_failed.)

Platform

  • Android
  • iOS
  • Web
  • Desktop

Platform OS version
iOS 17.5 (Simulator)

How are you picking?

final files = await FilePicker.pickFiles(type: FileType.any);

Details to reproduce the issue

This reproduces in the iOS Simulator.

  1. On a Mac, make two package-format documents in TextEdit. For each, create a new document, type a line of text, and choose File › Save…, with "Rich Text Document with Attachments" for "File Format", saving on the Desktop:

    • with-image.rtfd: before saving, also drag in an image file from Finder, ending in .jpg, .jpeg, .heic, .heif or .png.
    • no-image.rtfd: just the text.

    In Finder, each shows as a single document, and Show Package Contents shows what's inside.

  2. Open the iOS Simulator (open -a Simulator). Drag both documents onto the Simulator window, and save them in Files, under On My iPhone.

  3. Create the repro app, with the lib/main.dart below, and run it in the Simulator:

    flutter create --platforms=ios rtfd_repro
    cd rtfd_repro
    flutter pub add file_picker:13.1.0
    # Replace lib/main.dart with the file below, then:
    flutter run
  4. In the app, tap Pick a document, and pick with-image.rtfd.

    • Expected: name: with-image.rtfd, or an error saying package documents aren't supported.
    • Actual: the name: line says <image name>, and the path: line shows it inside the copied package.
  5. Pick no-image.rtfd.

    • Expected: name: no-image.rtfd, or an error saying package documents aren't supported.
    • Actual: an error, with code load_failed and message None of the picked items could be loaded.. (This is accurate. A more targeted code and message would be an optional improvement.)
Repro app: lib/main.dart
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 the .rtfd from Files.';

  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}').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('Package document repro')),
      body: ListView(padding: const EdgeInsets.all(16), children: [
        FilledButton(onPressed: _pick, child: const Text('Pick a document')),
        const SizedBox(height: 16),
        SelectableText(_log),
      ]));
  }
}

Error Log

N/A

Screenshots and/or video

Screen.Recording.2026-10-14.at.3.52.20.PM.mov

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) [487ms]
    ! 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,903ms]
    • 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) [1,063ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 17F113
    • CocoaPods version 1.17.0

[✓] Chrome - develop for the web [6ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Connected device (5 available) [6.6s]
    • Pixel 8 (mobile)                   • 38101FDJH00CK4                       • android-arm64  • Android 17 (API 37)
    • Chris’s iPhone (wireless) (mobile) • 00008110-000924383632801E            • 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 [258ms]
    • All expected network resources are available.

! Doctor found issues in 2 categories.

Additional context

Claude Code helped me trace this in the source (file_picker_darwin 2.3.1):

The document picker passes each pick through copyToTemporaryDirectory, which calls resolveActualFile on the copy. resolveActualFile was added for Live Photos (#2157), which arrive as .pvt directories. But a document can be a directory too, and for one, it returns the first image file at the package's top level, or nothing if there is none.

#2158 meant resolveActualFile to cover "any other package-like result iOS might return", treating the folder as a wrapper around what the user wanted to pick. That fits a Live Photo, where you want to pick the still image, but not a package-format document: there, the folder is what the user meant to pick, and any images inside are only part of it.

Suggestion: apply resolveActualFile only to photo-picker results.

Related: #2260 is about the case resolveActualFile was written for, Live Photos. Its suggestion would make resolveActualFile unnecessary for photo-picker results, so the function could be removed, which would fix this issue too.

Activity

  1. added
    new issueAn issue that hasn't yet been seen from the maintainer
    on Oct 14, 2026
  2. vicajilau commented on Oct 15, 2026

    @vicajilau
    Owner

    Fixed in file_picker_darwin 2.3.2 (#2264), already on pub.dev. As you suggested, resolveActualFile is gone, so a package document like an .rtfd is returned as the package itself, with or without images inside. Thanks!

  3. added a commit that references this issue on Oct 15, 2026
    d38bc6b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    new issueAn issue that hasn't yet been seen from the maintainer

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions