firebaseapis 套件透過 API 發現服務提供自動產生的客戶端程式庫,以存取 Google API。專為 Flutter 和 Dart 所設計,能透過從官方 API 描述產生類型安全的 API,實現與 Firebase 及其他 Google 服務的無縫整合。這讓開發者可直接在其應用程式中與 Google 巨大的生態系統(例如 Drive、日曆和雲端儲存)互動,支援 Android、iOS、Web、macOS、Windows 與 Linux 平台。此套件由 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.