0

I have CustomScrollView which I have SliverFixedExtentList and SliverList inside. I put a PageView inside delegate of SliverFixedExtentList. The thing is after scrolling to bottom and opening a detail page and returning back It gives me this exception which I don’t quite understand :

 ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (25339): The following assertion was thrown while finalizing the widget tree:
I/flutter (25339): 'package:flutter/src/widgets/scroll_position.dart': Failed assertion: line 661 pos 12: 'pixels !=
I/flutter (25339): null': is not true.

Do you have any idea what’s going on? Here is the gist to produce the issue: https://gist.github.com/figengungor/e03704744d0ef786a15ecb783060f730 (

Figen Güngör
  • 12,169
  • 14
  • 66
  • 108

1 Answers1

1

This seems like a recurrent bug when using tab widgets. There is an open issue on github which seems to address other cases close related to yours.

On your case this seems to happen when your PageView widget loses screen focus. Although this is not a good solution (but does solve the error), it should help you:

Declare a ScrollController :

class HomePageState extends State<HomePage> {
    ScrollController _scrollController = new ScrollController();
    ...

Assign it to your CustomScrollView:

CustomScrollView(
    controller: _scrollController,
    ...

Before going to another page, scroll your list up to make the PageView widget visible:

_openSecondPage(BuildContext context) {
     _scrollController.animateTo(0.0, duration: Duration(milliseconds: 1), curve: Curves.bounceInOut);
     Navigator.of(context).push(MaterialPageRoute(builder: (_) => SecondPage()));
    ...

You should save the scroll position to scroll to the position when the item was clicked.

PS: Open an issue on the flutter github to a better visibility about this.

Zroq
  • 8,002
  • 3
  • 26
  • 37