Deprecating RenderSliverFillViewport

217 views
Skip to first unread message

Weiyu Huang

unread,
Aug 13, 2019, 6:40:51 PM8/13/19
to Flutter Public Announcements (flutter-announce)
As a part of this PR: https://github.com/flutter/flutter/pull/37024/files, I propose to deprecate the RenderSliverFillViewport class.
This should only affect those who are using the SliverFillViewport widget or RenderSliverFillViewport directly. 

# Why deprecating RenderSliverFillViewport?

Currently RenderSliverFillViewport has a few bugs in its implementation, such as https://github.com/flutter/flutter/issues/23873. With the introduction of SliverLayoutBuilder, the functionality of RenderSliverFillViewport can be perfectly replicated at the widget level, without those bugs. 
Instead of continuing to maintain RenderSliverFillViewport, deprecating it in favor of SliverLayoutBuilder seems to be more appealing, as SliverLayoutBuilder is more generic, composable and it is a widget.

# Migration Path

Mostly like no migration will be needed for code that's not using `RenderSliverFillViewport` directly. 

If you're using `SliverFillViewport`, it should continue to work, except when viewportFraction > 1 the initial scroll offset will be 0 instead of a negative number and you may have to override ViewportOffset.applyContentDimensions to counteract this. Please refer to https://github.com/flutter/flutter/pull/37024/files#diff-1a81a2201f7f040eaa1caca883740526R429-R436 for example. 

If you're using `RenderSliverFillViewport`, consider replacing it with a SliverLayoutBuilder at the widget level.

If I can be of any help in porting code or answering questions, please contact me directly or add a comment to the pull request: https://github.com/flutter/flutter/pull/37024

Weiyu Huang

unread,
Aug 13, 2019, 8:28:03 PM8/13/19
to Flutter Public Announcements (flutter-announce)
If you're using RenderSliverFillViewport or its subclasses, and it's not feasible to convert to SliverLayoutBuilder, consider subclassing RenderSliverFixedExtentBoxAdaptor
A minimal implementation of a render sliver class that fills the main axis of the view port would look like:

class RenderSliverFillViewport extends RenderSliverFixedExtentBoxAdaptor {
  RenderSliverFillViewport({
    @required RenderSliverBoxChildManager childManager,
  }) : super(childManager: childManager);

  @override
  double get itemExtent => constraints.viewportMainAxisExtent;
}

Reply all
Reply to author
Forward
0 new messages