Skip to content

Conversation

russellwheatley
Copy link
Member

@russellwheatley russellwheatley commented Jul 3, 2024

Description

I created a button to attach three listeners to a document ref:

ElevatedButton(
  onPressed: () async {
    final collection = FirebaseFirestore.instance
        .collection('flutter-tests')
        .doc('blah');

    collection.snapshots().listen((data) {
      print('Data: ${data.data()}');
    });
    collection.snapshots().listen((data) {
      print('Data: ${data.data()}');
    });
    collection.snapshots().listen((data) {
      print('Data: ${data.data()}');
    });
  },
  child: const Text('Create Listeners'),
),

Here are the logs. The following proves the fix:

  • On initial start up, I created listeners which correctly printed the data 3 times.
  • "hot restart" 3 times and created listeners again. Correctly printed the data 3 times.
  • "hot restart" 1 more time and created listeners again. Correctly printed the data 3 times.
  • Updated the data on Firebase console by removing the property "ed". Correctly printed the data 3 times to prove their are no duplicate listeners.
The Flutter DevTools debugger and profiler on Chrome is available at: http://127.0.0.1:9101?uri=http://127.0.0.1:53058/tqTueP2OMDk=
Data: {foo: bar, ed: YYYYY}
Data: {foo: bar, ed: YYYYY}
Data: {foo: bar, ed: YYYYY}

Performing hot restart...                                           83ms
Restarted application in 83ms.

Performing hot restart...                                           39ms
Restarted application in 39ms.

Performing hot restart...                                           44ms
Restarted application in 44ms.
Data: {foo: bar, ed: YYYYY}
Data: {foo: bar, ed: YYYYY}
Data: {foo: bar, ed: YYYYY}

Performing hot restart...                                           49ms
Restarted application in 49ms.
Data: {foo: bar, ed: YYYYY}
Data: {foo: bar, ed: YYYYY}
Data: {foo: bar, ed: YYYYY}
Data: {foo: bar}
Data: {foo: bar}
Data: {foo: bar}

Related Issues

fixes #13019

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. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • 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 (melos run analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • 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.
  • No, this is not a breaking change.

@russellwheatley russellwheatley marked this pull request as ready for review July 3, 2024 12:01
@russellwheatley russellwheatley merged commit 110dfae into master Jul 9, 2024
@russellwheatley russellwheatley deleted the firestore-13019 branch July 9, 2024 13:05
@firebase firebase locked and limited conversation to collaborators Aug 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[firebase_firestore]: Stream does not load value, but future does on web
3 participants