搜尋套件、儲存庫與 APP 分類

套件詳情v0.2.0

firebaseapis

透過 API 發現服務描述的 Google API 的自動產生客戶端程式庫。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
2.1萬
喜歡數
21
Pub 分數
160

安裝套件

flutter pub add firebaseapis

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

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

Chat on Discord

melos

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).

See ./generated/firebaseapis/README.md for information on all the currently supported APIs.

Usage Example

// Import the APIs you want to use
import 'package:firebaseapis/firebaseremoteconfig/v1.dart' as remote_config;
import 'package:firebaseapis/firebaserules/v1.dart' as firebase_rules;
// Import Auth client
import 'package:googleapis_auth/auth_io.dart' as auth;

// Get an Auth Client
final authClient = await auth.clientViaApplicationDefaultCredentials(scopes: [
  remote_config.FirebaseRemoteConfigApi.cloudPlatformScope,
]);

// Call some APIs
final rc = remote_config.FirebaseRemoteConfigApi(authClient);
final config =
  await rc.projects.getRemoteConfig('projects/<your-project-id>');
print(config.parameters);
print(config.parameters?.values.first.defaultValue);
print(config.parameters?.values.first.description);
print(config.parameters?.values.first.valueType);

final fr = firebase_rules.FirebaseRulesApi(authClient);
final rules =
  await fr.projects.rulesets.list('projects/<your-project-id>');
print(rules.rulesets?.first.name);
print(rules.rulesets?.first.source?.files?.first.content);

Custom Request Headers

Custom request headers can be set by adding to requestHeaders:

import 'package:firebaseapis/src/user_agent.dart';

Future<void> main() async {
  requestHeaders.addAll({
    'cool-header': 'cool-value',
  });
  print(requestHeaders);
}

Contributing

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;

  1. Add the API to the apis list in ./config.yaml
  2. 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.
  3. Run melos run config:generate to generate new Dart library code for the API, which outputs to ./generated/firebaseapis.

Maintained by Invertase.

所屬分類

依賴

依賴清單 2 項

  • _discoveryapis_commons^1.0.0
  • http>=0.13.0 <2.0.0

原始碼儲存庫

使用此套件的專案