You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

是否有谷歌官方支持的Flutter文件选择器插件?

Official File Picker for PDFs & Images in Flutter

Hey there! Let's break down what you need to know about Google-official file picker options for your Flutter project:

Current Official Plugins

  • image_picker: As you already noted, this official plugin is built specifically for selecting images and videos—it doesn't support PDFs or other document types.
  • file_selector: This is the official solution you're looking for! Maintained by the Flutter team (backed by Google), it lets users pick files from the device's file system, including PDFs, images, and a wide range of other file types. It works seamlessly across Android, iOS, web, desktop, and more.

Why file_selector Fits Your Needs

  • It’s officially supported, so you get reliable updates and alignment with Flutter’s core ecosystem.
  • You can easily filter allowed file types (like PDFs and common image formats) to restrict what users can select.
  • It follows Flutter’s cross-platform best practices, making integration straightforward.

Quick Usage Example

To limit selections to PDFs and images, here’s a snippet to get you started:

import 'package:file_selector/file_selector.dart';

Future<void> pickTargetFile() async {
  final typeGroup = XTypeGroup(
    label: 'PDFs & Images',
    extensions: ['pdf', 'jpg', 'jpeg', 'png'],
  );
  final pickedFile = await openFile(acceptedTypeGroups: [typeGroup]);
  
  if (pickedFile != null) {
    // Handle your selected file here
  }
}

Comparing to file_picker

While the third-party file_picker is a popular and capable option, file_selector offers the peace of mind of official Google-backed support. Both plugins work well, but if prioritizing official maintenance is key for your project, file_selector is the clear choice.


内容的提问来源于stack exchange,提问作者GoPro

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 04:49:00