firebase / flutterfire

πŸ”₯ A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.46k stars 3.91k forks source link

[firebase_database] Web support for realtime database #1835

Closed awazgyawali closed 2 years ago

awazgyawali commented 4 years ago

Description

This PR will add support to realtime database for Web

Related Issues

https://github.com/flutter/flutter/issues/48542

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

tmthecoder commented 4 years ago

Any progress as to the addition of web support for database?

Greatcallie commented 4 years ago

We are waiting for this!

Mylab6 commented 4 years ago

Will this be done soon ?

Does anyone have a work around ?

awazgyawali commented 4 years ago

Sorry for disappearing. I was super busy at work. The current progress of the task is

The interface has been built and works fine on mobile but on the web, the referencing is getting overlapped. It's quite complicated for me to have a look and fix it with very little spare time. I'll try to look back again and give a more detailed progress report.

If any of you guys wanna share hand then please let me know, let's get this done together,

googlebot commented 4 years ago

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

pc-brainants commented 4 years ago

@googlebot I signed it!

googlebot commented 4 years ago

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

googlebot commented 4 years ago

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

pc-brainants commented 4 years ago

@googlebot I consent.

googlebot commented 4 years ago

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

jackyq2015 commented 4 years ago

Any reason this PR cannot be merged?

awazgyawali commented 4 years ago

Because of its a work in progress @jackyq2015

awazgyawali commented 4 years ago

@collinjackson @kroikie @bean5 Hi guys, I am getting very near to the finish line and I don't think this PR will ever make sense to be reviewed as its a very big change on a single thread. I would like to get a bit of advice, will it be better if I sent the multiple separate PRs one by one or should I continue on this one?

Also here was my plan for the breakdown of this PR

  1. Move firebase_messaging to firebase_messaging/firebase_messaging
  2. Add platform interface package
  3. Migrate to platform interface
  4. Add database web plugin
  5. Add web plugin to firebase_database dependencies
  6. Update example
  7. Update README

Let me know if any change is needed.

Jemshi101 commented 4 years ago

Any updates on the PR?. i hope this PR will be merged soon.. :)

ditman commented 4 years ago

@collinjackson @kroikie @bean5 Hi guys, I am getting very near to the finish line and I don't think this PR will ever make sense to be reviewed as its a very big change on a single thread. I would like to get a bit of advice, will it be better if I sent the multiple separate PRs one by one or should I continue on this one?

Also here was my plan for the breakdown of this PR

Move firebase_messaging to firebase_messaging/firebase_messaging Add platform interface package Migrate to platform interface Add database web plugin Add web plugin to firebase_database dependencies Update example Update README Let me know if any change is needed.

Hey @awazgyawali! There's value on having a PR with the whole code, so people can clone it and apply it to their apps. We used this with cloud_firestore and it was invaluable. However:

You should move firebase_database to firebase_database/firebase_database ASAP, in a separate PR. That one is very quick to do, and it'd make the rest of your PRs a little bit simpler.

Then you can have one big PR (could be this one) where you display the finished PoC for manual verification. When we did this for cloud_firestore, I had a local, silly app that tested as many features as possible as a local testbed. For firestore database, a mix of this and this could be enough! The example app of firebase_database may be another good candidate for this.

This is the PR that receives the most scrutiny, and where most of the work happens, with everything integrated so it continues to be testable. All verification tests should pass, except for the "publishable" one, because of the "path" dependencies across the three plugins.

Once we're all happy with the PR, then you can do 3 (simple again) PRs, where you split the codebase of this one into 3 next PRs:

  1. Add (and publish) the platform interface plugin
  2. Migrate the core plugin to the platform interface implementation, and remove old code.
  3. Introduce (and publish) the web plugin.

Now all that is left is updating the core package to use the web version automatically, and update the example app so it supports web (normally, adding a web/index.html, and removing usages of dart:io, if any :P)

/PS: Paging @Ehesp for assistance with this big, big change!

awazgyawali commented 4 years ago

Thanks for the detailed explanation @ditman.

You should move firebase_database to firebase_database/firebase_database ASAP, in a separate PR.

I'll send the PR ASAP.

The example app of firebase_database may be another good candidate for this.

I have added all the possible features running on android, ios, and web on the example app as well. So that part should be good to go.

... everything integrated so it continues to be testable. All verification tests should pass, except for the "publishable" one, because of the "path" dependencies across the three plugins.

Ok, I'll make sure of that in a couple of days.

Once I finish all the above tasks, ill get back to the thread for further discussion.

ditman commented 4 years ago

Thanks for your contribution @awazgyawali!!

Salakar commented 4 years ago

We'll provide an update later on this week on how we can move this PR forwards and what we can do to help - if necessary.

Please hold of any substantial work until then, thanks πŸ‘

1g0rrr commented 4 years ago

Hi, I would love to use this plugin In my project these days. Do we have some movements here? Maybe some help needed?

Ehesp commented 4 years ago

We'll use this PR as the base to work on database, as part of https://github.com/FirebaseExtended/flutterfire/issues/2582 - it's a great PR, however we need to ensure that it's fully tested and covered API review wise before we can merge.

awazgyawali commented 4 years ago

Hi, @Ehesp I just went through the Roadmap and it looks really promising. This PR is not finalized in terms of testing as no new test cases have been written for the web platform but as of my manual testing, everything seems to work fine without any breaking changes. Also this PR doesn't have support for runTransaction method on the web as it's not supported by the underlying firebase plugin.

But right now, I am waiting for @Salakar for his comment on this before I start working on the points made by @ditman (https://github.com/FirebaseExtended/flutterfire/pull/1835#issuecomment-630336875)

I have mentioned everyone here so that we all are synced up with the current status of the PR.

Thanks!!!!

1g0rrr commented 3 years ago

Can you guys please suggest, how to apply this PR to my project before it will be released? I spend a couple of hours trying to do this, but there are errors. Is there a command to do this?

awazgyawali commented 3 years ago

Can you guys please suggest, how to apply this PR to my project before it will be released? I spend a couple of hours trying to do this, but there are errors. Is there a command to do this?

Clone the repo somewhere near to your project, and reference it as follows:

firebase_database:
    path: ../{to the folder where the repo is}/firebase_database/firebase_database

I myself have not done it but should work.

byrek3d commented 3 years ago

Hi @awazgyawali, first of all let me congratulate you on the great work done so far!

I had some free time and I tried adding your repository to my existing flutter application that uses firebase_database. After resolving some easy to fix conflicts, I am now getting this error:

Error: MissingPluginException(No implementation found for method Query#observe on channel plugins.flutter.io/firebase_database)

I also get a bunch of messages like this: Overflow on channel: plugins.flutter.io/firebase_database. Messages on this channel are being discarded in FIFO fashion. The engine may not be running or you need to adjust the buffer size if of the channel.

Any idea what can be done here?

awazgyawali commented 3 years ago

@byrek3d Sorry to hear that it didn't work on your project. Its been around about a month since I last worked on this PR. From what I remember, everything except runTransaction was working. Can you share me your query which caused this issue so that I can look into it easily?

byrek3d commented 3 years ago

I would if I could, but the error message really doesn't help narrow it down to what piece of code is causing this. I tried debugging by using simple prints, and my best guess is that it comes from this piece of code:

_clientQuery = database.reference().child("client"); _onClientAddedSubscription = _clientQuery.onChildAdded.listen(_onEntryAdded); _onClientChangedSubscription = _clientQuery.onChildChanged.listen(_onEntryChanged); _onClientRemovedSubscription = _clientQuery.onChildRemoved.listen(_onEntryRemoved);

ditman commented 3 years ago

@byrek3d if you're getting MethodChannel errors, it's because your version of the plugin may not be using the platform_interface package that @awazgyawali added here (or that it is not 100% complete)

Regards!

awazgyawali commented 3 years ago

@byrek3d I checked the PR back again yesterday. It's working fine for me. I don't know if it's because of Flutter version mismatch. But I would be more than grateful if you tried running the example project that comes along with the repo.

1g0rrr commented 3 years ago

I tested this PR for a week now, and all works great in my project! Thanks for this work. Hope it will be merged soon

awazgyawali commented 3 years ago

Amazing to hear @1g0rrr Is there any issue or missing features that you might have encountered except runTransaction.

byrek3d commented 3 years ago

@1g0rrr May I ask what changes you made to your current project in oder to get it to run? I added these two in my pubsec.yaml

firebase_database: path: ../../../database_web_cloning/flutterfire/packages/firebase_database/firebase_database firebase_database_web: path: ../../../database_web_cloning/flutterfire/packages/firebase_database/firebase_database_web

But now I can't run on the simulator anymore (pod install error, more precisely this: -> Fetching podspec for 'firebase_database_web' from '.symlinks/plugins/firebase_database_web/ios' [!] No podspec found for 'firebase_database_web' in '.symlinks/plugins/firebase_database_web/ios' ) and when I run on the web I get this error:

TypeError: dart.global.firebase.database is not a function

1g0rrr commented 3 years ago

@byrek3d Here is how I managed to do this. I copy the whole PR repo, and then deleted unnecessary folders. Image 5

MichealReed commented 3 years ago

Has anyone tested .onDisconnect()? I cannot get a set or a remove operation to complete after the window is closed.

awazgyawali commented 3 years ago

Hey @awazgyawali! There's value on having a PR with the whole code, so people can clone it and apply it to their apps. We used this with cloud_firestore and it was invaluable. However:

You should move firebase_database to firebase_database/firebase_database ASAP, in a separate PR. That one is very quick to do, and it'd make the rest of your PRs a little bit simpler.

Then you can have one big PR (could be this one) where you display the finished PoC for manual verification. When we did this for cloud_firestore, I had a local, silly app that tested as many features as possible as a local testbed. For firestore database, a mix of this and this could be enough! The example app of firebase_database may be another good candidate for this.

This is the PR that receives the most scrutiny, and where most of the work happens, with everything integrated so it continues to be testable. All verification tests should pass, except for the "publishable" one, because of the "path" dependencies across the three plugins.

Once we're all happy with the PR, then you can do 3 (simple again) PRs, where you split the codebase of this one into 3 next PRs:

  1. Add (and publish) the platform interface plugin
  2. Migrate the core plugin to the platform interface implementation, and remove old code.
  3. Introduce (and publish) the web plugin.

Now all that is left is updating the core package to use the web version automatically, and update the example app so it supports web (normally, adding a web/index.html, and removing usages of dart:io, if any :P)

/PS: Paging @Ehesp for assistance with this big, big change!

I think it's now time to move ahead as a lot of fellow developers are waiting on this. I will start the breakdown process from tomorrow. I hope it gets reviewed soon.

awazgyawali commented 3 years ago

The first PR has been published. https://github.com/FirebaseExtended/flutterfire/pull/2852

dev-mush commented 3 years ago

Don't mean to give any hurry but my project is heavily relying on this, any idea on when this will be merged? I'm happy to offer help if needed!

MichealReed commented 3 years ago

@dev-mush I setup a fork that allows you to easily add this to your pubspec while we wait for a PR.


firebase_database:
    git:
      url: https://github.com/MichealReed/flutterfire
      ref: realtime_database_web_support
      path: packages/firebase_database/firebase_database
  firebase_database_web:
    git:
      url: https://github.com/MichealReed/flutterfire
      ref: realtime_database_web_support
      path: packages/firebase_database/firebase_database_web```
byrek3d commented 3 years ago

Hi everyone! Last time I was reporting some errors in my project, but I am now certain that it was just my bad when modifying the pubsec.yaml

Using what @MichealReed provided was much simpler and worked like a charm.

Now my app is partially working on the web, I can see that it reads a list of objects from my firebase database correctly, but when trying to access another list of objects from my database (that's what my app normally does, it's a list of "people" each having different "files") it is crashing.

I really can't figure out how to debug on firebase_web, but here is the error output i get:

══║ EXCEPTION CAUGHT BY WIDGETS LIBRARY β•žβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
The following assertion was thrown building Builder:
Assertion failed:
file:///Users/gerald/Workspaces/FlutterProjects/flutter/.pub-cache/git/flutterfire-4bff36815227cf9b064bf21bf5e2a777ce43de83/packages/firebase_database/firebase_database_platform_interface/lib/src/platform_interface/query.dart:27:16
database != null
is not true

The relevant error-causing widget was:
  MaterialApp
  file:///Users/gerald/Workspaces/FlutterProjects/clone_web_test/TimeSheet/time_sheet/lib/main.dart:17:13

When the exception was thrown, this was the stack:
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 214:49           throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 24:3             assertFailed
packages/firebase_database_platform_interface/src/platform_interface/query.dart 27:24  new
packages/firebase_database_web/src/query_web.dart 15:3                                 new
packages/firebase_database_web/src/database_reference_web.dart 91:12                   orderByChild
packages/firebase_database/src/query.dart 106:28                                       orderByChild
packages/time_sheet/pages/files_page.dart 63:10                                        initState
packages/flutter/src/widgets/framework.dart 4649:58                                    [_firstBuild]
packages/flutter/src/widgets/framework.dart 4485:5                                     mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 5839:14                                    mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 4490:5                                     [_firstBuild]
packages/flutter/src/widgets/framework.dart 4485:5                                     mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 5839:14                                    mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 5839:14                                    mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4684:11                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 4490:5                                     [_firstBuild]
packages/flutter/src/widgets/framework.dart 4675:11                                    [_firstBuild]
packages/flutter/src/widgets/framework.dart 4485:5                                     mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 5956:32                                    mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4684:11                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 4490:5                                     [_firstBuild]
packages/flutter/src/widgets/framework.dart 4675:11                                    [_firstBuild]
packages/flutter/src/widgets/framework.dart 4485:5                                     mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 5839:14                                    mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4684:11                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 4490:5                                     [_firstBuild]
packages/flutter/src/widgets/framework.dart 4675:11                                    [_firstBuild]
packages/flutter/src/widgets/framework.dart 4485:5                                     mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 5839:14                                    mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4684:11                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 4490:5                                     [_firstBuild]
packages/flutter/src/widgets/framework.dart 4675:11                                    [_firstBuild]
packages/flutter/src/widgets/framework.dart 4485:5                                     mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 5839:14                                    mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4684:11                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 4490:5                                     [_firstBuild]
packages/flutter/src/widgets/framework.dart 4675:11                                    [_firstBuild]
packages/flutter/src/widgets/framework.dart 4485:5                                     mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 4490:5                                     [_firstBuild]
packages/flutter/src/widgets/framework.dart 4485:5                                     mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4684:11                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 4490:5                                     [_firstBuild]
packages/flutter/src/widgets/framework.dart 4675:11                                    [_firstBuild]
packages/flutter/src/widgets/framework.dart 4485:5                                     mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 5839:14                                    mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 4490:5                                     [_firstBuild]
packages/flutter/src/widgets/framework.dart 4485:5                                     mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 5839:14                                    mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4684:11                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 4490:5                                     [_firstBuild]
packages/flutter/src/widgets/framework.dart 4675:11                                    [_firstBuild]
packages/flutter/src/widgets/framework.dart 4485:5                                     mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 4490:5                                     [_firstBuild]
packages/flutter/src/widgets/framework.dart 4485:5                                     mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 5839:14                                    mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 4490:5                                     [_firstBuild]
packages/flutter/src/widgets/framework.dart 4485:5                                     mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4684:11                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 4490:5                                     [_firstBuild]
packages/flutter/src/widgets/framework.dart 4675:11                                    [_firstBuild]
packages/flutter/src/widgets/framework.dart 4485:5                                     mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 4490:5                                     [_firstBuild]
packages/flutter/src/widgets/framework.dart 4485:5                                     mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 4490:5                                     [_firstBuild]
packages/flutter/src/widgets/framework.dart 4485:5                                     mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4684:11                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 4490:5                                     [_firstBuild]
packages/flutter/src/widgets/framework.dart 4675:11                                    [_firstBuild]
packages/flutter/src/widgets/framework.dart 4485:5                                     mount
packages/flutter/src/widgets/framework.dart 3455:13                                    inflateWidget
packages/flutter/src/widgets/framework.dart 3223:18                                    updateChild
packages/flutter/src/widgets/framework.dart 5589:32                                    updateChildren
packages/flutter/src/widgets/framework.dart 5966:17                                    update
packages/flutter/src/widgets/framework.dart 3210:14                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4684:11                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 4716:5                                     update
packages/flutter/src/widgets/framework.dart 3210:14                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 4871:5                                     update
packages/flutter/src/widgets/inherited_notifier.dart 181:11                            update
packages/flutter/src/widgets/framework.dart 3210:14                                    updateChild
packages/flutter/src/widgets/framework.dart 5846:14                                    update
packages/flutter/src/widgets/framework.dart 3210:14                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4684:11                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 4716:5                                     update
packages/flutter/src/widgets/framework.dart 3210:14                                    updateChild
packages/flutter/src/widgets/framework.dart 5846:14                                    update
packages/flutter/src/widgets/framework.dart 3210:14                                    updateChild
packages/flutter/src/widgets/framework.dart 5846:14                                    update
packages/flutter/src/widgets/framework.dart 3210:14                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 4592:5                                     update
packages/flutter/src/widgets/framework.dart 3210:14                                    updateChild
packages/flutter/src/widgets/framework.dart 4536:16                                    performRebuild
packages/flutter/src/widgets/framework.dart 4684:11                                    performRebuild
packages/flutter/src/widgets/framework.dart 4227:5                                     rebuild
packages/flutter/src/widgets/framework.dart 2632:31                                    buildScope
packages/flutter/src/widgets/binding.dart 864:20                                       drawFrame
packages/flutter/src/rendering/binding.dart 284:5                                      [_handlePersistentFrameCallback]
packages/flutter/src/scheduler/binding.dart 1113:15                                    [_invokeFrameCallback]
packages/flutter/src/scheduler/binding.dart 1052:9                                     handleDrawFrame
packages/flutter/src/scheduler/binding.dart 968:5                                      [_handleDrawFrame]
lib/_engine/engine/window.dart 725:13                                                  _invoke
lib/_engine/engine/window.dart 338:5                                                   invokeOnDrawFrame
lib/_engine/engine.dart 213:18                                                         <fn>

═════════════════════════════
═══════════════════════════════════════════════════════════════════════
awazgyawali commented 3 years ago

@byrek3d Can you post a minimal reproducible code. As per thr error message an assertion on this line is failing /firebase_database/firebase_database_platform_interface/lib/src/platform_interface/query.dart:27:16

Also as #2582 is moving hot and I will not probably maintain this PR until firebase_core changes are stable.

awazgyawali commented 3 years ago

@Salakar I don't see any status report for Realtime Database on the Flutterfire road map issue #2582. Has the refactor for Realtime database been ditched?

Salakar commented 3 years ago

@Salakar I don't see any status report for Realtime Database on the Flutterfire road map issue #2582. Has the refactor for Realtime database been ditched?

Not ditched, shifted to early next year, as mentioned on the Roadmap we're looping back to polish off the web implementation on all the plugins we reworked for native, so Web is definitely still getting attention.

rahulvyas commented 3 years ago

@dev-mush I setup a fork that allows you to easily add this to your pubspec while we wait for a PR.

firebase_database:
    git:
      url: https://github.com/MichealReed/flutterfire
      ref: realtime_database_web_support
      path: packages/firebase_database/firebase_database
  firebase_database_web:
    git:
      url: https://github.com/MichealReed/flutterfire
      ref: realtime_database_web_support
      path: packages/firebase_database/firebase_database_web```

Ok what are the next steps after importing dependencies ? How do we use this in dart file ?

I've tried importing like this

import 'package:firebase_database/firebase_database.dart' if (dart.library.html) 'package:firebase/firebase.dart'; Getting this error when running on chrome

[ +204 ms] lib/Services/WSFirebaseServices.dart:18:9: Error: Type 'FirebaseDatabase' not found.
[        ]   final FirebaseDatabase _firebaseDatabase = FirebaseDatabase.instance;
[        ]         ^^^^^^^^^^^^^^^^
[+1298 ms] lib/WSDashboardPage.dart:695:27: Error: A value of type 'DataSnapshot/*1*/' can't be assigned to a variable of type 'DataSnapshot/*2*/'.
[        ]  - 'DataSnapshot/*1*/' is from 'package:firebase/src/database.dart' ('../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.3/lib/src/database.dart').
[        ]  - 'DataSnapshot/*2*/' is from 'package:firebase_database/firebase_database.dart' ('../../../development/flutter/.pub-cache/git/flutterfire-4bff36815227cf9b064bf21bf5e2a777ce43de83/packages/firebase_database/firebase_database/lib/firebase_database.dart').

Update Only import which is required is import 'package:firebase_database/firebase_database.dart'; And in index.html

<script src="https://www.gstatic.com/firebasejs/7.15.5/firebase-storage.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.15.5/firebase-database.js"></script>

After these my app runs on web and I got assertion failure same as @byrek3d @awazgyawali

rahulvyas commented 3 years ago

@byrek3d Can you post a minimal reproducible code. As per thr error message an assertion on this line is failing /firebase_database/firebase_database_platform_interface/lib/src/platform_interface/query.dart:27:16

Also as #2582 is moving hot and I will not probably maintain this PR until firebase_core changes are stable.

I'm also getting some exception can you tell me what's wrong

Error: Assertion failed: file:///Users/sysquare/development/flutter/.pub-cache/git/flutterfire-4bff36815227cf9b064bf21bf5e2a777ce43de83/packages/firebase_database/firebase_database_platform_interface/lib/src/platform_interface/query.dart:27:16
            database != null
            is not true
                at Object.throw_ [as throw] (http://localhost:55510/dart_sdk.js:4338:11)
                at Object.assertFailed (http://localhost:55510/dart_sdk.js:4281:15)
                at firebase_database_web.QueryWeb.new.firebase_database_platform_interface.QueryPlatform.new (http://localhost:55510/packages/firebase_database_platform_interface/firebase_database_platform_interface.dart.lib.js:331:35)
                at new firebase_database_web.QueryWeb.new (http://localhost:55510/packages/firebase_database_web/firebase_database_web.dart.lib.js:405:50)
                at firebase_database_web.DatabaseReferenceWeb.new.orderByChild (http://localhost:55510/packages/firebase_database_web/firebase_database_web.dart.lib.js:203:14)
                at firebase_database.DatabaseReference.__.orderByChild (http://localhost:55510/packages/firebase_database/firebase_database.dart.lib.js:106:71)
                at WSFirebaseServices.FireBaseStorage.new.getUserByEmail (http://localhost:55510/packages/WoodStock/Services/WSFirebaseServices.dart.lib.js:90:74)
                at getUserByEmail.next (<anonymous>)
                at runBody (http://localhost:55510/dart_sdk.js:37922:34)
                at Object._async [as async] (http://localhost:55510/dart_sdk.js:37953:7)
                at WSFirebaseServices.FireBaseStorage.new.getUserByEmail (http://localhost:55510/packages/WoodStock/Services/WSFirebaseServices.dart.lib.js:89:20)
                at WSLoginController.MyCustomFormState.new.login (http://localhost:55510/packages/WoodStock/WSDashboardPage.dart.lib.js:4413:37)
                at login.next (<anonymous>)
                at http://localhost:55510/dart_sdk.js:37902:33
                at _RootZone.runUnary (http://localhost:55510/dart_sdk.js:37756:58)
                at _FutureListener.thenAwait.handleValue (http://localhost:55510/dart_sdk.js:32717:29)
                at handleValueCallback (http://localhost:55510/dart_sdk.js:33265:49)
                at Function._propagateToListeners (http://localhost:55510/dart_sdk.js:33303:17)
                at _Future.new.[_completeWithValue] (http://localhost:55510/dart_sdk.js:33145:23)
                at async._AsyncCallbackEntry.new.callback (http://localhost:55510/dart_sdk.js:33168:35)
                at Object._microtaskLoop (http://localhost:55510/dart_sdk.js:38017:13)
                at _startMicrotaskLoop (http://localhost:55510/dart_sdk.js:38023:13)
                at http://localhost:55510/dart_sdk.js:33520:9
carloshwa commented 3 years ago

Can this PR get some love again now that firebase_core is stable?

arlucio commented 3 years ago

I would love to have some official update on this, or at least some kind of mention of it on the roadmap.

The way it is right now, is quite hard to have any ideia of the status of this.

Salakar commented 3 years ago

Hey all, I created and merged https://github.com/FirebaseExtended/flutterfire/pull/5887 a few days ago which moves packages/firebase_database to packages/firebase_database/firebase_database in the repository - which is a good start to be able to start taking PRs for Database web support.

This PR itself is so far out of date (not the authors fault) that I don't think we can move forward with this one, there's been significant restructures, CI changes and updates happening across the repository. That said I don't think we should just discard the work that's happened here.

If contributors are willing I'd like to propose the following;

  1. A separate PR to improve integration test coverage, it's historically been pretty bare; I wouldn't feel comfortable shipping or reviewing the significant changes that 2 & 3 would require without first improving our integration tests coverage.
  2. Using this PR as a reference; a separate PR to federate the firebase_database plugin and implement the firebase_database_platform_interface package. Depends on 1.
  3. Using this PR as a reference; a separate PR to implement web support (firebase_database_web). Depends on 1 & 2.

Whilst firebase_database isn't currently a package officially in our scope (@invertase) right now, we're still willing to help see the above contributions through to merging if people are willing. Historically PRs may have sat and become stale, but this is no longer the case now (we've shipped almost 100 PRs in the last month) - so there hopefully shouldn't be any concern there.

If you're picking up any of the points above, please reply below so others are aware. If you need assistance with contributing or have any queries on implementation detail then please reach out to me also.

SpajicM commented 3 years ago

Whilst firebase_database isn't currently a package officially in our scope (@invertase) right now

@Salakar Why? Isn't RTBD a first-class Firebase citizen, on same level as Firestore, Storage etc. First it got suddenly removed from Roadmap, and now this, I'm a bit confused.

russellwheatley commented 2 years ago

Thanks for the contribution @awazgyawali but we're closing this PR in favour of: https://github.com/FirebaseExtended/flutterfire/pull/6952