I was thinking of developing a desktop application with dart and flutter but i don't know how can i integrate Firebase database with it. Any suggestions will be appreciated. Thanks in advance
FlutterFire is the official Firebase packages for Flutter apps, most of which currently support iOS, Android, web, and macOS, but for all of them, Linux and Windows platforms are missing.
The only ways to connect with Firebase are by an Android, an iOS and a web app. There is no support for desktop apps. But, you can create a native sync service to link your desktop app with Firebase users throught a web service.
If you don't already have a Flutter app, you can complete the Get Started: Test Drive to create a new Flutter app using your preferred editor or IDE. Before you can add Firebase to your Flutter app, you need to create a Firebase project to connect to your app. Visit Understand Firebase Projects to learn more about Firebase projects.
In the above firebase versions, the firebase_core supports null safety while the firebase_database still doesn’t, so also when you want to run the application you need to do flutter run --no-sound-null-safety or if you are using android studio then check this link.
Google’s Flutter SDK can be used to develop apps that give native UI experience for both Android and iOS platforms. To write apps using Flutter, you have to use Dart programming language. Firebase Realtime Database is a cloud-hosted database with data stored as JSON.
Firebase helps developers to build and run their apps successfully, its backend developed by Google. Firebase is very easy to use for beginners, it provides many functionalities like Firebase Authentication, Cloud Firestore, Realtime Database, Firebase Storage, etc which help to build and optimize the application.
Use Firedart package to integrate FIrebase to Desktop-based Flutter apps.
https://pub.dev/packages/firedart
Documentation Says
This library attempts to minimize dependencies with the intention of making it able to run in any environment capable of executing dart code. Currently it has been successfully tested using the dart runtime (x86-64 and arm32) as well as on Flutter Android, iOS and Desktop.
I connect Firebase with my windows flutter app using http method; code and snapshot are below. Firebase real time database work perfectly. i follow this tutorial https://medium.com/flutterdevs/http-request-dcc13e885985
my code is:
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
sendData();
}
sendData() {
http.post(
Uri.parse(
"https://rest-12bb2-default-rtdb.firebaseio.com/userprofile.json"),
body: json.encode({
'firstName': "b",
'lastName': "c",
'email': "f",
}));
// setState(() {
// userProfile.add(Profile(
// firstName: firstname;
// lastName: lastname;
// email: email;
// ));
// });
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("app"),
),
body: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(
'You have pushed the button this many times:',
),
new Text(
'$_counter',
style: Theme.of(context).textTheme.display1,
),
],
),
),
floatingActionButton: new FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: new Icon(Icons.add),
),
);
}
}
///////////// firebase snapshotenter image description here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With