25

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

D. Go.
  • 407
  • 1
  • 9
  • 22

5 Answers5

14

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.

Fathah Cr
  • 441
  • 1
  • 8
  • 17
  • Doesnt seem to be currently working. Following the example code in the docs I get an error `Handling error gRPC Error (code: 1, codeName: CANCELLED, message: Disconnecting idle stream. Timed out waiting for new targets` – West Sep 21 '21 at 07:03
  • Better write a new question instead of commenting. As the error is irrelevant to this issue. – Fathah Cr Sep 22 '21 at 06:23
7

Context: As of 24/02/2021 the main project for supporting firebase services in Flutter can be found here. If you look at this issue raised on GitHub it provides a rough roadmap for the project which is looking at the "possibility" of supporting desktop.

An issue has been opened to provide support for Windows and Linux.

Answer: Right now the best options to use Firebase with your desktop application is to either -

  1. Read the documentation for each firebase service and see if they support RESTful API requests to interact with the service. For example Cloud Firestore supports this.
  2. firedart is an open source attempt to provide an API for some Firebase services.
  3. Wait for ("hopefully") Google to provide a package written natively in dart.
Rob
  • 164
  • 1
  • 4
  • The issue is now a discussion (feature request) https://github.com/FirebaseExtended/flutterfire/discussions/5557 – tbdrz Apr 02 '21 at 13:59
  • I am writing a Windows desktop app in Flutter, that shares much code with a mobile phone app that runs nicely, and on Firebase.initializeApp I get the infamous "missingpluginexception(no implementation found for method firebase#initializecore on channel plugins.flutter.io/firebase_core)" error. And apparently this happens because Windows is not yet supported. I tried to switch to firedart, that is quite nice, but it does not support FirebaseStorage, i.e. storage of files, especially images. Auth and Firebase DB work fine, though, with minor code changes. Will wait for Windows support. – Michael Uhlenberg May 23 '21 at 15:19
  • @MichaelUhlenberg Have you used FirebaseStorage on Desktop? – Deepak sharma Feb 08 '22 at 20:34
  • @Deepak sharma: do you mean https://pub.dev/packages?q=firebasestorage ? No. Does not work on Windows. I looked again right now and it seems nothing has changed yet. I wonder if there are any principal reasons why Windows is not supported. – Michael Uhlenberg Feb 10 '22 at 14:28
  • 1
    Hi, for anyone who is interested in the official flutterfire desktop. please upvote for the feature request in the link below. thanx! https://firebase.uservoice.com/forums/948424-general/suggestions/46591750-desktop-windows-linux-macos-support-for-flutte – HW Kim Jun 09 '23 at 17:32
5

The main FlutterFire page has a table that shows what Firebase products work in which environment.

Right now that shows that these products are supported in macOS desktop apps:

  • Cloud Firestore
  • Cloud Functions
  • Firebase Authentication
  • Firebase Crashlytics
  • Firebase Storage

If you're having problems making one of these work, edit your question to include the minimal information with which we can reproduce where you got stuck and any error messages you're getting.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • 1
    Can I use these products in windows app? – D. Go. Jul 05 '20 at 17:32
  • 2
    The documentation I linked only mentions macOS, and the [main Flutter desktop documentation](https://flutter.dev/desktop) also says that Windows and Linux are under even more active development. On the other hand, posts such as [this one](https://medium.com/flutter/flutter-and-desktop-3a0dd0f8353e) show that some folks have gotten a Flutter app working on Windows. If you are having problems getting it to work, post what you've tried and where you got stuck and somebody may try to help. – Frank van Puffelen Jul 05 '20 at 18:33
  • 1
    None of the FlutterFire plugins support Windows or Linux; that's why only macOS is listed in the chart. – smorgan Jul 05 '20 at 20:21
  • 1
    Have you checked ```firedart``` . https://pub.dev/packages/firedart In the documentation, it says that the package can be used in any dart based apps. – Fathah Cr Oct 11 '20 at 08:18
  • @FathahKodag I looked through my entire browser history so I could find this comment again. I needed to use Firestore on Flutter - Windows, and firedart worked for me. Thanks a lot! – Zac Apr 04 '21 at 22:56
4

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

Khurram
  • 173
  • 7
0

you can use Firebase C++ SDK :

https://firebase.google.com/docs/cpp/setup#desktop-workflow

arvin
  • 9
  • 1