カテゴリー・パッケージ・リポジトリを検索

パッケージ詳細v1.0.3

firebase_database_rest

REST をベースにした、Firebase Realtime Database API 用のプラットフォーム非依存型 Dart/Flutterラッパー。

30日間ダウンロード
38
いいね数
18
Pub ポイント
140

パッケージをインストール

flutter pub add firebase_database_rest

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

プラットフォームに依存しないDart/Flutterパッケージで、Firebase Realtime Database用のRESTベースのラッパーを提供します。HTTPリクエストを使用してFirebaseデータベースとシームレスにやり取りでき、ネイティブのFirebase SDKが利用できない環境に適しています。このパッケージは低レベルのREST呼び出しを直感的なDartメソッドに抽象化し、ポーリングによるデータの読み取り・書き込みおよびリアルタイム更新をサポートします。シンプルさと複数プラットフォームでの互換性を重視しており、プラットフォーム固有のプラグインに依存せずにFirebase統合が必要なアプリに最適です。

用途

  • クロスプラットフォームでのFirebaseデータベースアクセス
  • サーバーサイドのFlutterアプリケーション
  • Web およびデスクトップアプリの統合
  • オフライン優先のシナリオとマニュアル同期
  • 軽量な Firebase インタラクション

主な機能

  • REST APIベースの通信
  • プラットフォームに依存しない設計
  • シンプルな CRUD 操作
  • ポーリングベースのリアルタイム更新
  • ネイティブSDKの依存関係なし

適している対象

  • Webまたはデスクトップ向けの開発者
  • ネイティブのFirebaseプラグインを避けるプロジェクト
  • Flutterを使用したバックエンドサービス
  • 軽量なFirebaseアクセスを必要とするアプリ

注意事項

  • リアルタイム更新の手動処理
  • ネイティブSDKよりも高い遅延
  • REST互換機能に制限されています
  • 組み込みのオフライン永続化なし
  • 手動でのエラー処理と再試行ロジックが必要です

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

firebase_database_rest

Continous Integration Pub Version

A platform independent Dart/Flutter Wrapper for the Firebase Realtime Database API based on REST

Features

  • Pure Dart-based implementation
    • works on all platforms supported by dart
  • Uses the official REST-API endpoints
  • Provides high-level classes to manage database access
  • Supports Model-Binding via Generics and converter functions
  • Full support of all Realtime database features:
    • Supports CRUD
    • Supports Queries (filtering, sorting)
    • Supports realtime server updates (streaming)
    • Supports ETags
  • Provides a Transaction class to wrap ETag-Logic into safe transactions
  • Provides timestamp class for server set timestamps
  • Proivides low-level REST classes for direct API access (import firebase_database_rest/rest.dart)
  • Fully integrated with firebase_auth_rest - including automatic auth token refreshes

Installation

Simply add firebase_database_rest to your pubspec.yaml and run pub get (or flutter pub get).

Usage

The libraries primary class is the FirebaseStore. It is a high-level class that allows access to a certain part of the realtime database using Model binding. With this store, you specify a subpatch and can then perform various operations on elements below that path (list key, create, read, write or delete them, ...). This class also provides the APIs for streaming changes and transactions. Typically, your application would use multiple stores, one for each dataclass you plan to store at a certain path.

The second important class is the FirebaseDatabase. It serves as the toplevel class, parent to all stores and manages the database connection itself, including the management of the associated FirebaseAccount (from firebase_auth_rest) and background ressources (like the REST-API interface).

The following code is a simple example, which can be found in full length, including errorhandling, at https://pub.dev/packages/firebase_database_rest/example. It loggs into firebase as anonymous user, starts streaming changes and then does some db operations.

// The data class that is stored in firebase
class ExampleModel {
  final int id;
  final String data;

  const ExampleModel(this.id, this.data);
  
  // ...
}

// obtain a firebase account, using firebase_auth_rest
final account = // ...

// create a database reference from that account
final database = FirebaseDatabase(
  account: account,
  database: 'my-firebase-realtime-database-name,
  basePath: 'application/${account.localId}/example',
);

// create typed store. In this example, a callback store is used, but you can
// also just extend FirebaseStore
final store = database.createRootStore<ExampleModel>(
  onDataFromJson: (dynamic json) => ExampleModel.fromJson(json),
  onDataToJson: (data) => data.toJson(),
  onPatchData: (data, updatedFields) => data.patch(updatedFields),
);

// add a stream listener that reports database changes in realtime
sub = (await store.streamAll()).listen((e) => print('Stream update: $e'));

// add some data to the store
await store.create(const ExampleModel(1, 'A'));

// get all data in store
print('All data: ${await store.all()}');

// cleanup: stop streaming and dispose of the database
await sub.cancel();
await database.dispose();

Documentation

The documentation is available at https://pub.dev/documentation/firebase_database_rest/latest/. A full example can be found at https://pub.dev/packages/firebase_database_rest/example.

カテゴリー

依存関係

依存関係一覧 6 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。