Cross-platform APIs for Firebase.
- crossfire - platform-agnostic firebase API
- crossfire_flutter - flutter implementation
- crossfire_web - web implementation
- Firebase Auth (currently only with custom tokens)
- Firestore (collections and documents)
- Cloud Storage
Build your API using a crossfire
Firebase
object:
import 'package:crossfire/crossfire.dart';
class MyFancyApp {
final Firebase _firebase;
MyFancyApp(this._firebase);
}
and build some API methods:
import 'package:crossfire/crossfire.dart';
class MyFancyApp {
final Firebase _firebase;
MyFancyApp(this._firebase);
Future saveData() async {
var docRef = await _firebase.getDocument("path/to/doc");
docRef.setData({"hello": "firebase"});
}
}
Then inject the Firebase
implementation based on the platform:
import 'package:crossfire/crossfire.dart';
import 'package:crossfire_web/crossfire_web.dart';
FirebaseConfiguration configuration;
Future setupMyApp() async {
var firebase = new FirebaseWeb();
await firebase.init(configuration);
var app = new MyFancyApp();
}
import 'package:crossfire/crossfire.dart';
import 'package:crossfire_web/crossfire_flutter.dart';
FirebaseConfiguration configuration;
Future setupMyApp() async {
var firebase = new FirebaseFlutter();
await firebase.init(configuration);
var app = new MyFancyApp();
}
note: a FirebaseConfiguration usually looks something like this:
FirebaseConfiguration configuration;
void setupConfig() {
configuration = new FirebaseConfiguration(
apiKey: "<API_KEY>",
databaseUrl: "https://mydb.firebaseio.com",
storageBucket: "myapp.appspot.com",
projectId: "myproject",
iosGoogleAppId: "1:111111111111:ios:22222222222222222",
androidGoogleAppId: "1:111111111111:android:22222222222222222",
);
}