Skip to main content
Point your Firebase Flutter SDK at Lark by passing your Lark URL to FirebaseDatabase.instanceFor(). Everything else — listeners, writes, queries — works without changes.

Setup

Add the Realtime Database plugin to your pubspec.yaml:
dependencies:
  firebase_core: ^3.0.0
  firebase_database: ^11.0.0
Then run:
flutter pub get

Connect to Lark

Pass your Lark URL when getting the database instance:
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_database/firebase_database.dart';

await Firebase.initializeApp();

// Change this from https://PROJECT_ID.firebaseio.com
final database = FirebaseDatabase.instanceFor(
  app: Firebase.app(),
  databaseURL: 'https://your-lark-project-id.larkdb.net',
);

final ref = database.ref('players/alice');
If your firebase_options.dart (generated by FlutterFire CLI) already has the databaseURL, you can update it there instead and use FirebaseDatabase.instance directly.

Project settings

Before connecting, make sure your Lark project is configured correctly:
  1. Allow Legacy Firebase must be enabled in your Lark project settings. This turns on the Firebase wire protocol.
  2. If your Firebase app stores many independent data silos under path prefixes (game rooms, workspaces, etc.), see Database routing for options on splitting them into separate Lark databases.