Skip to content

[cloud_firestore] List.contains doesn't compare DocumentReference correctly #2019

Closed
@stuied148

Description

@stuied148

Describe the bug
The List.compare() method always returns false when comparing a DocumentReference with List<DocumentReference>. This bug doesn't produce an error in console, but it's effects are visible when certain code can't be reached.
This bug exists in cloud_firestore: 0.13.0 and above.
This bug doesn't exist in cloud_firestore: 0.12.11.

To Reproduce
Steps to reproduce the behavior:

  1. Create a List<DocumentReference> from firestore data.
  2. Pass a valid DocumentReference into the List.contains() method.
List<DocumentReference> favorites = List.from(userDocument['favorites']);
        if (favorites.contains(documentReference)) {
          // This is never reached
        }
  1. The List.contains() method always returns false, even if the list contains the DocumentReference. There is no error thrown.

Expected behavior
The List.compare() method should return true if the List<DocumentReference> contains the passed DocumentReference. It should only return false if the List doesn't contain the DocumentReference.

Additional context
Firebase versions:

firebase_core: ^0.4.4
cloud_firestore: ^0.13.2+2

Flutter doctor:

[√] Flutter (Channel beta, v1.14.6, on Microsoft Windows [Version 10.0.18362.657], locale en-GB)
    • Flutter version 1.14.6 at C:\src\flutter
    • Framework revision fabeb2a16f (3 weeks ago), 2020-01-28 07:56:51 -0800
    • Engine revision c4229bfbba
    • Dart version 2.8.0 (build 2.8.0-dev.5.0 fc3af737c7)


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\stuie\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
    • All Android licenses accepted.

[√] Android Studio (version 3.5)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 43.0.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

Metadata

Metadata

Assignees

No one assigned

    Labels

    impact: crowdAffects many people, though not necessarily a specific customer with an assigned label. (P2)plugin: cloud_firestoretype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions