anchor.diff:      bool visible = false;
       int firstIndex = 0;
       int lastIndex = 0;
  -    int firstIndexNextBlock;
   
       StaggeredGridConfiguration configuration =
           _gridDelegate.getConfiguration(constraints);
   
       double pageSize = configuration.mainAxisOffsetsCacheSize * constraints.viewportMainAxisExtent;
       int pageIndex = scrollOffset ~/ pageSize;
  -    double trailingPageOffset = (pageIndex + 1 ) * pageSize;
  -
  -    debugPrint('pageSize=$pageSize, pageIndex=$pageIndex, trailingPageOffset=$trailingPageOffset');
  -
  -    _ViewportOffsets _viewportOffset;
  -    if(_viewportOffsets.isEmpty){
  -      _viewportOffset= new _ViewportOffsets(
  -          0.0,
  -          0,
  -          configuration.generateMainAxisOffsets());
  -      _viewportOffsets.add(_viewportOffset);
  +
  +    // If the viewport is resized, we keep the in memory the old offsets caches. (Useful if only the orientation changes multiple times).
  +    if(pageSize == 1836.0)
  +      {
  +        debugPrint('portrait');
  +      }
  +    SplayTreeMap<int, _ViewportOffsets> viewportOffsets = _pageSizeToViewportOffsets.putIfAbsent(pageSize, () => new SplayTreeMap<int, _ViewportOffsets>());
  +
  +    debugPrint('pageSize=$pageSize, pageIndex=$pageIndex');
  +
  +    _ViewportOffsets viewportOffset;
  +    if(viewportOffsets.isEmpty){
  +      viewportOffset= new _ViewportOffsets(configuration.generateMainAxisOffsets(), pageSize);
  +      viewportOffsets[0] = viewportOffset;
       }else{
  -      _viewportOffset = _viewportOffsets[pageIndex];
  -    }
  -
  -    debugPrint('viewport offsets length: ${_viewportOffsets.length}');
  -    debugPrint('viewport offset $_viewportOffset');
  +      int smallestKey = viewportOffsets.lastKeyBefore(pageIndex + 1);
  +      viewportOffset = viewportOffsets[smallestKey];
  +    }
  +
  +    debugPrint('viewport offsets length: ${viewportOffsets.length}');
  +    debugPrint('viewport offset $viewportOffset');
   
       // A staggered grid always have to layout the child from the zero-index based one to the last visible.
  -    var mainAxisOffsets = _viewportOffset.mainAxisOffsets.toList();
  +    var mainAxisOffsets = viewportOffset.mainAxisOffsets.toList();
       HashSet<int> visibleIndices = new HashSet<int>();
   
       // Iterate through all children while they can be visible.
  -    for (var index = _viewportOffset.firstIndex;
  +    for (var index = viewportOffset.firstChildIndex;
           mainAxisOffsets.any((o) => o <= targetEndScrollOffset);
           index++) {
         SliverStaggeredGridGeometry geometry =
  
positive.code:       lastIndex = index;
      }
  
      //debugPrint('Iterated from $firstIndex to $lastIndex');
  
      collectGarbage(visibleIndices);
  
      if (!visible) {
        geometry = SliverGeometry.zero;
        childManager.didFinishLayout();
        return;
      }
  
  
negative.code: 
  class _ViewportOffsets {
    _ViewportOffsets(
    List<double> mainAxisOffsets,
        this.trailingScrollOffset,
        [
        this.pageIndex = 0,
        this.firstChildIndex = 0,
      ]
    ) : this.mainAxisOffsets = new List.from(mainAxisOffsets);
  
    final int pageIndex;
  
    final int firstChildIndex;
  
    final double trailingScrollOffset;
  
    final List<double> mainAxisOffsets;
  
    @override
    String toString() => '[$pageIndex-$trailingScrollOffset] ($firstChildIndex, $mainAxisOffsets)';
  }
  
  /// Creates staggered grid layouts.
  