File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed
packages/flutter/lib/src/widgets Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -3191,15 +3191,21 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
31913191 }
31923192 late int _depth;
31933193
3194+ /// Returns result < 0 when [a] < [b] , result == 0 when [a] == [b] , result > 0
3195+ /// when [a] > [b] .
31943196 static int _sort (Element a, Element b) {
3195- if (a.depth < b.depth)
3196- return - 1 ;
3197- if (b.depth < a.depth)
3198- return 1 ;
3199- if (b.dirty && ! a.dirty)
3200- return - 1 ;
3201- if (a.dirty && ! b.dirty)
3202- return 1 ;
3197+ final int diff = a.depth - b.depth;
3198+ // If depths are not equal, return the difference.
3199+ if (diff != 0 ) {
3200+ return diff;
3201+ }
3202+ // If the `dirty` values are not equal, sort with non-dirty elements being
3203+ // less than dirty elements.
3204+ final bool isBDirty = b.dirty;
3205+ if (a.dirty != isBDirty) {
3206+ return isBDirty ? - 1 : 1 ;
3207+ }
3208+ // Otherwise, `depth`s and `dirty`s are equal.
32033209 return 0 ;
32043210 }
32053211
You can’t perform that action at this time.
0 commit comments