1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] SliverAppBar not scrolling when nested ListView uses a ScrollController

Discussão em 'Mobile' iniciado por Stack, Outubro 9, 2024 às 10:22.

  1. Stack

    Stack Membro Participativo

    Minimum reproducible code:

    final _controller = ScrollController();

    @override
    Widget build() {
    return NestedScrollView(
    headerSliverBuilder: (_, __) => [SliverAppBar(expandedHeight: 300)],
    body: ListView.builder(
    controller: _controller, // Removing this solves the issue.
    itemCount: 100,
    itemBuilder: (_, i) => Text('$i'),
    ),
    );
    }


    If I scroll my ListView, the SliverAppBar doesn't scroll but if I remove the controller property then it does scroll.

    So, how can I use the controller and make the SliverAppBar to scroll with the ListView (i.e. the standard behavior)?


    Note: I don't want to use the CustomScrollView as my tree hierarchy won't let me make use of it that well.

    Continue reading...

Compartilhe esta Página