firebase_database_dart_platform library
An implementation of FlutterFire's Realtime Database platform interface on
top of the pure-Dart client firebase_database_dart.
An app keeps the official firebase_database API
(FirebaseDatabase.instance.ref('notes').onValue), and
firebase_database_dart does the work underneath, over the Realtime
Database WebSocket protocol:
- On Linux, where neither
firebase_databasenorfirebase_corehas an implementation, adding this package is enough: Flutter calls FirebaseDatabaseDart.registerWith beforemain. That registration has no token provider and no persistence: the connection carries no user and keeps its data in memory, unlessmaincalls FirebaseDatabaseDart.use with them before the first use. - On Windows, the same when the app lists this package as a direct
dependency: it replaces the native
firebase_databaseplugin. - On any other platform, call FirebaseDatabaseDart.use at the start of
main, before the first use of Firebase, to replace the official implementation.
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
FirebaseDatabaseDart.use(
tokenProviderFor: (FirebaseApp app) => FirebaseAuthDart.userAuthFor(app),
);
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
await FirebaseDatabase.instance.ref('notes/today').set('Hello');
}
Classes
- DartFirebaseDatabase
-
The implementation of
DatabasePlatformon top offirebase_database_dart: one instance per FlutterFire app and database (see forApp). - FirebaseDatabaseDart
-
Selects
firebase_database_dartas the implementation of the officialfirebase_databasepackage.
Typedefs
- AppCheckProviderFactory = AppCheckTokenProvider? Function(FirebaseApp app)
-
Returns the App Check token provider of the Realtime Database connection of
the FlutterFire
app, or null for a connection without an App Check token. - DatabasePersistenceFactory = DatabasePersistence Function(int cacheSizeBytes)
-
Returns the persistence of the clients of this package, for the cache
size the app set with
FirebaseDatabase.setPersistenceCacheSizeBytes(10 MiB when it set none), for example(int cacheSizeBytes) => sqlitePersistence(directory, cacheSizeBytes: cacheSizeBytes)offirebase_database_dart_sqlite. - TokenProviderFactory = AuthTokenProvider? Function(FirebaseApp app)
-
Returns the token provider that the Realtime Database connection of the
FlutterFire
appauthenticates with, or null for a connection without a user.