pulyaevskiy/firebase-admin-interop
Firebase Admin Interop Library for Dart
go to github downloadWrite server-side Firebase applications in Dart using Node.js as a runtime.
Firestore Timestamps migration:
Firestore deprecated usage of DateTime objects in favor of custom Timestamp type and recommends
migrating as soon as possible.
By default all timestamps are still returned as DateTime objects and you can access them with
DocumentData.getDateTime
orDocumentData.setDateTime
.
To start using Timestamps you must configure Firestore as follows:final app = FirebaseAdmin.instance.initializeApp(); final firestore = app.firestore(); // Call Firestore.settings at the very beginning before any other calls: firestore.settings(FirestoreSettings(timestampsInSnapshots: true)); // You can read and write data now, but make sure to use new `setTimestamp` and `getTimestamp` // methods of `DocumentData`.
Installation
- Add this package as a dependency to your
pubspec.yaml
:
dependencies:
firebase_admin_interop: [latest_version]
Run pub get
.
- Create
package.json
file to install Node.js modules used by this library:
{
"dependencies": {
"firebase-admin": "8.5.0",
"@google-cloud/firestore": "2.0.0"
}
}
Run npm install
.
Usage
Below is a simple example of using Realtime Database client:
import 'dart:async';
import 'package:firebase_admin_interop/firebase_admin_interop.dart';
Future<void> main() async {
final serviceAccountKeyFilename = '/absolute/path/to/service-account.json';
final admin = FirebaseAdmin.instance;
final cert = admin.certFromPath(serviceAccountKeyFilename);
final app = admin.initializeApp(new AppOptions(
credential: cert,
databaseURL: "YOUR_DB_URL",
));
final ref = app.database().ref('/test-path');
// Write value to the database at "/test-path" location.
await ref.setValue("Hello world");
// Read value from the same database location.
var snapshot = await ref.once("value");
print(snapshot.val()); // prints "Hello world".
}
Note that it is only possible to use JSON-compatible values when reading
and writing data to the Realtime Database. This includes all primitive
types (int
, double
, bool
), string values (String
) as well as
any List
or Map
instance.
For Firestore there are a few more supported data types, like
DateTime
andGeoPoint
.
Building
This library depends on node_interop package which provides Node.js
bindings and build_node_compilers package which allows compiling
Dart applications as Node.js modules.
To enable builders provided by build_node_compilers first add following
dev dependencies to your pubspec.yaml
:
dev_dependencies:
build_runner: ^1.0.0
build_node_compilers: ^0.2.0
Next, create build.yaml
file with following contents:
targets:
$default:
sources:
- "lib/**"
- "node/**" # Assuming your main Dart files is in node/ folder (recommended).
- "test/**"
builders:
build_node_compilers|entrypoint:
options:
compiler: dart2js # To compile with dart2js by default
You can now build your project using build_runner
:
# By default compiles with DDC
pub run build_runner build --output=build
# To compile with dart2js:
pub run build_runner build \
--define="build_node_compilers|entrypoint=compiler=dart2js" \
--define="build_node_compilers|entrypoint=dart2js_args=[\"--minify\"]" \ # optional, minifies resulting code
--output=build/
Status
This library is considered stable though not feature complete. It is recommended to check
dev versions for latest updates and bug fixes.
Make sure to checkout CHANGELOG.md
after every release, all notable changes and upgrade instructions will
be described there.
Current implementation coverage report:
- [x] admin
- [x] admin.auth
- [x] admin.app
- [x] admin.credential
- [x] admin.database
- [x] admin.firestore
- [x] admin.messaging
- [ ] admin.storage
Features and bugs
Please file feature requests and bugs at the issue tracker.
![](/images/banner-woo.jpg)
excellent projects related to pulyaevskiy/firebase-admin-interop recommend downloading
localsend
33797
An open-source cross-platform alternative to AirDrop
gsy_github_app_flutter
14559
Flutter 超完整的开源项目,功能丰富,适合学习和日常使用。GSYGithubApp系列的优势:我们目前已经拥有Flutter、Weex、ReactNative、kotlin 四个版本。 功能齐全,项目框架内技术涉及面广,完成度高,持续维护,配套文章,适合全面学习,对比参考。跨平台的开源Github客户端App,更好的体验,更丰富的功能,旨在更好的日常管理和维护个人Github,提供更好更方便的驾车体验Σ( ̄。 ̄ノ)ノ。同款Weex版本 : https://github.com/CarGuo/GSYGithubAppWeex 、同款React Native版本 : https://github.com/CarGuo/GSYGithubApp 、原生 kotlin 版本 https://github.com/CarGuo/GSYGithubAppKotlin
dio
12249
A powerful HTTP client for Dart and Flutter, which supports global settings, Interceptors, FormData, aborting and canceling a request, files uploading and downloading, requests timeout, custom adapters, etc.
bloc
11441
A predictable state management library that helps implement the BLoC design pattern
getx
9899
Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get.
flame
8846
A Flutter based game engine.
flutter_deer
7595
🦌 Flutter 练习项目(包括集成测试、可访问性测试)。内含完整UI设计图,更贴近真实项目的练习。Flutter practice project (including integration testing and accessibility testing). Contains complete UI design drawings for a more realistic practice project.
fl_chart
6451
FL Chart is a highly customizable Flutter chart library that supports Line Chart, Bar Chart, Pie Chart, Scatter Chart, and Radar Chart.
riverpod
5828
A reactive caching and data-binding framework. Riverpod makes working with asynchronous code a breeze.
provider
5029
InheritedWidgets, but simple
getwidget
4416
Most popular and easy to use open source UI library with 1000+ Widgets to build flutter app.
fvm
4325
Flutter Version Management: A simple CLI to manage Flutter SDK versions.
pilipala
4003
PiliPala 是使用Flutter开发的BiliBili第三方客户端,感谢使用。
flutter_screenutil
3787
Flutter screen adaptation, font adaptation, get screen information
flutter_twitter_clone
3621
Fully functional Twitter clone built in flutter framework using Firebase realtime database and storage
flutter_rust_bridge
3608
Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
isar
3366
Extremely fast, easy to use, and fully async NoSQL database for Flutter
bruno
3126
An enterprise-class package of Flutter components for mobile applications. ( Bruno 是基于一整套设计体系的 Flutter 组件库。)
flutter_staggered_grid_view
3043
A Flutter staggered grid view
flutter_hooks
3030
React hooks for Flutter. Hooks are a new kind of object that manages a Widget life-cycles. They are used to increase code sharing between widgets and as a complete replacement for StatefulWidget.