Skip to content

[firebase_database] Web support for realtime database - #1835

Closed
awazgyawali wants to merge 40 commits into
firebase:masterfrom
awazgyawali:realtime_database_web_support
Closed

[firebase_database] Web support for realtime database#1835
awazgyawali wants to merge 40 commits into
firebase:masterfrom
awazgyawali:realtime_database_web_support

Conversation

@awazgyawali

@awazgyawali awazgyawali commented Jan 19, 2020

Copy link
Copy Markdown
Contributor

Description

This PR will add support to realtime database for Web

Related Issues

flutter/flutter#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.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • If the pull request affects only one plugin, the PR title starts with the name of the plugin in brackets (e.g. [cloud_firestore])
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

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

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

Comment thread packages/firebase_database/firebase_database/example/lib/main.dart
Comment thread packages/firebase_database/firebase_database/lib/src/database_reference.dart Outdated
@tmthecoder

Copy link
Copy Markdown

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

@Greatcallie

Copy link
Copy Markdown

We are waiting for this!

@Mylab6

Mylab6 commented Apr 1, 2020

Copy link
Copy Markdown

Will this be done soon ?

Does anyone have a work around ?

@awazgyawali

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown

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.

@ditman

ditman commented Jun 8, 2020

Copy link
Copy Markdown
Contributor

@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

Copy link
Copy Markdown
Contributor Author

@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

1g0rrr commented Jun 13, 2020

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor Author

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

@byrek3d

byrek3d commented Jun 13, 2020

Copy link
Copy Markdown

@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

1g0rrr commented Jun 13, 2020

Copy link
Copy Markdown

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

@MichealReed

Copy link
Copy Markdown

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

@awazgyawali

awazgyawali commented Jun 25, 2020

Copy link
Copy Markdown
Contributor Author

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

awazgyawali commented Jun 27, 2020

Copy link
Copy Markdown
Contributor Author

The first PR has been published.
#2852

@dev-mush

dev-mush commented Jul 7, 2020

Copy link
Copy Markdown

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

MichealReed commented Jul 7, 2020

Copy link
Copy Markdown

@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

byrek3d commented Jul 14, 2020

Copy link
Copy Markdown

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

awazgyawali commented Jul 14, 2020

Copy link
Copy Markdown
Contributor Author

@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

Copy link
Copy Markdown
Contributor Author

@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

Salakar commented Nov 11, 2020

Copy link
Copy Markdown
Contributor

@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

rahulvyas commented Dec 3, 2020

Copy link
Copy Markdown

@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

Copy link
Copy Markdown

@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

Copy link
Copy Markdown

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

@arlucio

arlucio commented Apr 16, 2021

Copy link
Copy Markdown

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

Salakar commented Apr 27, 2021

Copy link
Copy Markdown
Contributor

Hey all, I created and merged #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

This comment has been minimized.

return completer.future;
platform.TransactionResultPlatform transactionResult =
await _delegate.runTransaction(
(platformTransaction) async => platformTransaction,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here transactionHandler from the function is not passed So the transaction is not working.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm working on another PR #6668


/// `Event` encapsulates a DataSnapshot and possibly also the key of its
/// previous sibling, which can be used to order the snapshots.
class EventPlatform {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need to create separate model classes for Platform. We can move the Event class for e.g, to the platform_interface (of course with the public constructor) and then we can export this class to use it in the firebase_database for e.g.

@russellwheatley

Copy link
Copy Markdown
Member

Thanks for the contribution @awazgyawali but we're closing this PR in favour of: #6952

@firebase firebase locked and limited conversation to collaborators Oct 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.