flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.27k stars 27.51k forks source link

SplayTreeMap omitting nodes with matching key/value pairs? #13504

Closed CharlesCleveJr closed 6 years ago

CharlesCleveJr commented 6 years ago

When using a SplayTreeMap to map key/value pairs of a Firebase node, I've found that nodes with matching key/value pairs only return 1 node and omit all others. Here is the code I'm using...

DartPad Example

final sorted = new SplayTreeMap<String,dynamic>.from(map, (a, b) => map[b]['rank'].compareTo(map[a]['rank']));

Here are examples of the nodes I'm returning...

var map = {
  "Vid2": {
    "imageString": "https://i.ytimg.com/vi/Amq-qlqbjYA/mqdefault.jpg",
    "title": "BLACKPINK - '마지막처럼 (AS IF IT'S YOUR LAST)' M/V",
    "rank": "2",
    "videoID": "Amq-qlqbjYA"
  },
  "Vid10": {
    "imageString": "https://i.ytimg.com/vi/KSH-FVVtTf0/mqdefault.jpg",
    "title": "EXO 엑소 'Monster' MV",
    "rank": "2",
    "videoID": "KSH-FVVtTf0"
  },
  "Vid6": {
    "imageString": "https://i.ytimg.com/vi/BVwAVbKYYeM/mqdefault.jpg",
    "title": "[MV] BTS(방탄소년단) _ DOPE(쩔어)",
    "rank": "2",
    "videoID": "BVwAVbKYYeM"
  }}

Is this an issue or am I using the wrong properties???

zoechi commented 6 years ago

As far as I know this is the intended behavior of SplayTreeMap

See also https://stackoverflow.com/questions/47664718/how-to-use-a-splaytreemap-on-firebase-snapshot-dictionary-in-dart-flutter/47669085#47669085

Hixie commented 6 years ago

This sounds like a Dart SDK issue. If you still believe this should be changed, please file it at dart-lang/sdk. Thanks.

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.