firebaseapis 包通过 API 发现服务为访问 Google API 提供了自动生成的客户端库。专为 Flutter 和 Dart 构建,它能够通过从官方 API 描述生成类型安全的 API,实现与 Firebase 及其他 Google 服务的无缝集成。这使开发者可以直接在 Android、iOS、Web、macOS、Windows 和 Linux 平台上,与其庞大的生态系统(如 Drive、日历和云存储)进行交互。该包由 invertase.io 维护,支持现代 Flutter 开发工作流程。
适合场景
与 Google Drive 集成
访问 Google 日历数据
从 Google 身份验证获取用户信息
管理云存储操作
与 Google 表格同步数据
连接到 YouTube 数据 API
主要特点
从官方 API 发现文档自动生成
类型安全的 Dart 接口
跨平台支持(Android、iOS、Web、macOS、Windows、Linux)
与 Firebase 项目的无缝集成
支持 OAuth2 认证流程
定期更新,包含新的 Google API 发布
适合对象
需要 Google API 访问权限的开发者构建应用程序
需要与多个 Google 服务集成的项目
跨平台应用程序,适用于所有主要操作系统
使用 Firebase 作为后端基础设施的团队
需要对 Google 服务进行安全、经过身份验证的 API 调用的应用程序
使用建议
需要了解 Google API 发现格式
身份验证设置(OAuth2)可能很复杂
大型生成的代码库可能会增加构建大小
除了生成的 API 参考文档外,文档有限
对于轻量级客户端即可满足的简单用例来说,不是理想选择
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
Firebase API Client Libraries for Dart
This is based on the googleapis.dart repository but instead aimed at supporting Firebase related APIs only. Additionally, this adds support for several unlisted (but discoverable) Firebase APIs that are not listed on the official discovery API that googleapis.dart uses (and is currently limited to) as well as several private APIs (APIs that require an API key to view discovery information).
This project uses Melos to manage the project and dependencies.
To install Melos, run the following command from your SSH client:
dart pub global activate melos
Next, at the root of your locally cloned repository bootstrap the projects dependencies:
melos bootstrap
The bootstrap command locally links all dependencies within the project without having to
provide manual dependency_overrides. This allows all
plugins, examples and tests to build from the local clone project.
You do not need to run flutter pub get once bootstrap has been completed.
Adding a new API
To add a new API and generate library code for it is fairly straightforward;
Run melos run config:download to update the downloaded discovery document JSON files that are in ./discovery.
Note: several APIs require an API key to be able to read the discovery information. Set a API_KEY environment variable before running the command to be able to download the discovery documents for these private APIs, e.g. API_KEY=<your-key-here> melos run config:download.
Run melos run config:generate to generate new Dart library code for the API, which outputs to ./generated/firebaseapis.