This repository was archived by the owner on Apr 29, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-14
lines changed Expand file tree Collapse file tree 2 files changed +17
-14
lines changed Original file line number Diff line number Diff line change @@ -36,8 +36,12 @@ public class SliverMultiBoxAdaptorParentData : ContainerParentDataMixinSliverLog
36
36
37
37
public bool keepAlive = false ;
38
38
39
- internal bool _keptAlive = false ;
39
+ public bool keptAlive {
40
+ get { return this . _keptAlive ; }
41
+ }
40
42
43
+ internal bool _keptAlive = false ;
44
+
41
45
public override string ToString ( ) {
42
46
return $ "index={ this . index } ; { ( this . keepAlive ? "keeyAlive; " : "" ) } { base . ToString ( ) } ";
43
47
}
@@ -80,6 +84,7 @@ bool _debugAssertChildListLocked() {
80
84
}
81
85
82
86
public override void insert ( RenderBox child , RenderBox after = null ) {
87
+ D . assert ( ! this . _keepAliveBucket . ContainsValue ( value : child ) ) ;
83
88
base . insert ( child , after : after ) ;
84
89
D . assert ( this . firstChild != null ) ;
85
90
D . assert ( ( ) => {
Original file line number Diff line number Diff line change @@ -355,29 +355,27 @@ protected override void performRebuild() {
355
355
this . _currentBeforeChild = null ;
356
356
D . assert ( this . _currentlyUpdatingChildIndex == null ) ;
357
357
try {
358
- int firstIndex = 0 ;
359
- int lastIndex = 0 ;
360
-
361
- if ( ! this . _childElements . isEmpty ( ) ) {
362
- firstIndex = this . _childElements . First ( ) . Key ;
363
- lastIndex = this . _childElements . Last ( ) . Key ;
364
- if ( this . _didUnderflow ) {
365
- lastIndex += 1 ;
366
- }
367
- }
368
-
369
- for ( int index = firstIndex ; index <= lastIndex ; ++ index ) {
358
+ void processElement ( int index ) {
370
359
this . _currentlyUpdatingChildIndex = index ;
371
360
Element newChild = this . updateChild ( this . _childElements . getOrDefault ( index ) , this . _build ( index ) ,
372
361
index ) ;
373
362
if ( newChild != null ) {
374
363
this . _childElements [ index ] = newChild ;
375
- this . _currentBeforeChild = ( RenderBox ) newChild . renderObject ;
364
+ var parentData = ( SliverMultiBoxAdaptorParentData ) newChild . renderObject . parentData ;
365
+ if ( ! parentData . keptAlive ) {
366
+ this . _currentBeforeChild = ( RenderBox ) newChild . renderObject ;
367
+ }
376
368
}
377
369
else {
378
370
this . _childElements . Remove ( index ) ;
379
371
}
380
372
}
373
+ // processElement may modify the Map - need to do a .toList() here.
374
+ this . _childElements . Keys . ToList ( ) . ForEach ( action : processElement ) ;
375
+ if ( this . _didUnderflow ) {
376
+ var lastKey = this . _childElements ? . Last ( ) . Key ?? - 1 ;
377
+ processElement ( lastKey + 1 ) ;
378
+ }
381
379
}
382
380
finally {
383
381
this . _currentlyUpdatingChildIndex = null ;
You can’t perform that action at this time.
0 commit comments