path_provider_tvos 包为 Flutter 插件 path_provider 提供了 tvOS(Apple TV)实现,使 Flutter 应用能够访问 Apple TV 上的标准目录,如应用文档、缓存和临时文件夹。它是 Flutter TV 插件生态系统的一部分,确保在 tvOS 平台上一致的文件路径处理。该包支持针对 Apple TV 构建的 Flutter 应用,使开发者能够在 tvOS 环境的限制下可靠地管理本地文件存储。
适合场景
访问 Apple TV 上的应用程序特定文档目录
存储缓存数据以供离线使用
管理 tvOS 应用中的临时文件
持久化用户偏好或设置
在 Apple TV 应用中处理媒体文件
主要特点
tvOS 特定的路径解析
与 Flutter 的 path_provider API 集成
支持文档、缓存和临时目录
最小开销且轻量
与其他 Flutter 平台保持一致
适合对象
为 Apple TV 构建应用的 Flutter 开发者
tvOS 上需要本地文件存储的应用
跨平台使用 path_provider 模式的项目
维护跨平台文件实用工具的团队
使用建议
仅适用于 tvOS 设备或模拟器
不支持 iOS 或 Android 平台
需要 Flutter TV SDK 设置
仅限文件系统路径,无网络功能
依赖于 flutter-tvos 插件生态系统
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
FlutterTV Plugins
Flutter plugins with Apple TV (tvOS) support, maintained by the
fluttertv.dev organization.
These are companions to flutter-tvos
— the Flutter tvOS custom embedder. Most are federated *_tvos
implementations of popular pub.dev plugins, produced with the
flutter-tvos plugin port tool and finished/verified by hand.
Published on pub.dev under the
fluttertv.dev
verified publisher. Add them like any other plugin (<name>_tvos: ^0.0.1).
List of plugins
Every plugin below has a tvOS implementation; full details (API
coverage, disabled regions, and porting notes) are available in each
package's README.md and PORTING_REPORT.md.
Then use the upstream plugin's API exactly as on iOS — the tvOS
implementation registers automatically. Once published these become
plain ^version dependencies.
A few packages need a writable directory and therefore also
path_provider_tvos: e.g. video_player_tvos (for
VideoPlayerController.file) and sqflite_tvos (for the database
path). Their READMEs note this.
How this repository was created
These packages were not hand-written from scratch. They were produced
with the flutter-tvos plugin port tool (part of
flutter-tvos) and then
verified — and where needed finished — by hand. This is the exact,
reproducible workflow.
For the full porter reference — every flag, what the transformer
does and doesn't do, and how to read the generated PORTING_REPORT.md
— see Porting an existing plugin
in the flutter-tvos docs. The summary below is the recipe we used to
produce this repo.
flutter-tvos plugin port takes an existing Apple plugin (the iOS or
macOS implementation package) and emits a federated *_tvos package.
# from a published pub.dev package (what we used):$TVOS plugin port --from-pub video_player_avfoundation \
--output plugins/packages/video_player_tvos --include-example
# or from git, or from a local path:$TVOS plugin port --from-git https://github.com/foo/bar.git --ref main --output ...
$TVOS plugin port ../some_plugin_ios --output ...
The exact upstream source for each package is recorded at the top of
its PORTING_REPORT.md (e.g. video_player_tvos ←
video_player_avfoundation, shared_preferences_tvos ←
shared_preferences_foundation, audioplayers_tvos ←
audioplayers_darwin).
What the porter does automatically:
Copies the upstream Dart lib/ (rewriting package: self-imports)
and federates through the upstream *_platform_interface.
Copies the native Swift/Objective-C into tvos/Classes/ and
generates a tvOS *.podspec (no dependency on the Flutter
CocoaPod — tvOS resolves Flutter.framework via search paths).
Makes tvOS follow the iOS code paths: widens #if os(iOS) →
(os(iOS) || os(tvOS)), ObjC #if TARGET_OS_IOS →
(TARGET_OS_IOS || TARGET_OS_TV), and @available / #available
/ API_AVAILABLEiOS <v> → also tvOS <v>.
Collapses modern multi-target / include/-modular SwiftPM packages
into one CocoaPods module (drops the macOS-only target).
Sets FLTAssetsPath so plugin asset lookup resolves on a real
Apple TV; sanitizes example pub-workspace / dependency_overrides
wiring.
Graceful partial port: an API that genuinely doesn't exist on
tvOS, used at type/top-level scope, is wrapped in #if !os(tvOS) /
#if !TARGET_OS_TV so the package still compiles with that feature
disabled, and every such region is listed in PORTING_REPORT.md
under "Disabled on tvOS". A compatibility database
(WebKit, SafariServices, CoreLocation, CoreTelephony,
AVAudioSession routing options, …) drives this.
2. Read the porting report
Every package gets a PORTING_REPORT.md: the source + version, the
tvOS build outlook, methods ported/stubbed, every disabled region with
the reason, and a checklist. Read it before trusting a port.
3. Verify
cd plugins/packages/<pkg>/example
flutter pub get
$TVOS build tvos --simulator --debug # must be green$TVOStest integration_test/<plugin>_test.dart -d <sim-udid>
# on a physical Apple TV (set your signing team):
DEVELOPMENT_TEAM=XXXXXXXXXX $TVOS run -d <device-udid>
Only a green simulator build (and, ideally, passing integration tests
on a real Apple TV) qualifies a package for this list.
4. Hand-finish where the porter can't
The porter is honest about its limits; some packages needed manual
work, all of it documented in their PORTING_REPORT.md:
path_provider_tvos — path_provider_foundation is a
dart:ffi/native-assets plugin the tvOS toolchain can't build, so the
porter only emits a skeleton. A real native implementation
(NSSearchPathForDirectoriesInDomains / NSTemporaryDirectory) was
written by hand.
flutter_secure_storage_tvos — Keychain works on tvOS; the
optional LAContext / .biometryAny / Secure-Enclave biometric
path (which tvOS lacks) was guarded out by hand.
audioplayers_tvos, flutter_tts_tvos — AVAudioSession
category options that don't exist on tvOS
(allowBluetooth, defaultToSpeaker, …) were mapped to no-ops.
sqflite_tvos — re-ported once the porter learned to collapse
single-target include/-modular SwiftPM packages.
5. Curate
Packages whose primary purpose can't work on tvOS, or that don't
build after best-effort, are removed rather than published broken (see
Evaluated but not provided).
See AUTHORING.md for the deeper per-plugin recipe.
Repository layout
plugins/├──packages/<plugin>_tvos/# one directory per plugin│├──lib/# Dart (federated impl)│├──tvos/Classes/# native Swift/ObjC│├──tvos/<plugin>.podspec# CocoaPods spec, tvOS 13+│├──example/# runnable tvOS example│├──PORTING_REPORT.md# port detail + checklist│├──README.mdCHANGELOG.mdLICENSE└──AUTHORING.md# how to add a new one
Contributing
Federate via the upstream *_platform_interface; suffix _tvos.
Target tvOS 13.0+; guard shared iOS code with #if os(tvOS).
Document API support and any disabled regions in the package README.md
and PORTING_REPORT.md so users can assess compatibility.