Flutter NestedScrollView не показывал плавающий SliverAppBar мгновенно? - PullRequest
1 голос
/ 10 июля 2020

Я попытался создать scrollview с плавающей SliverAppBar с NestedScrollView и добавить контент внутри CustomScrollView, мне нужно, чтобы он был разделен, потому что я также использовал плагин pull_to_refre sh для обработки запроса api. вверх, чтобы показать плавающий SliverAppBar, он не работал так, как я ожидал, он отображается только после того, как пользователь перестанет прокручивать

Есть ли способ добиться этого с помощью NestedScrollView? или, может быть, другой виджет, мне нужно поместить его отдельно от CustomScrollView, потому что если я использую плавающий SliverAppBar внутри CustomScrollView, мой индикатор загрузки будет перекрываться с плавающим SliverAppBar

это код, который я пробовал

Scaffold(
        body: SafeArea(
          child: Scrollbar(
            child: NestedScrollView(
                    headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
                        // These are the slivers that show up in the "outer" scroll view.
                        return <Widget>[
                            SliverAppBar(
                                title: const Text('Books Nested'), // This is the title in the app b
                                forceElevated: innerBoxIsScrolled,
                                floating: true,
                                snap: true,
                            ),
                        ];
                    },
                    body: CustomScrollView(
                        slivers: <Widget>[
                            SliverList(
                                delegate: SliverChildBuilderDelegate(
                                        (BuildContext context, int index) {
                                        return Container(
                                            margin: EdgeInsets.all(10.0),
                                            color: Colors.grey,
                                            constraints: BoxConstraints(
                                                minWidth: 100.0,
                                                maxHeight: 160.0
                                            ),
                                        );
                                    },
                                    childCount: 30
                                ),
                            ),
                        ],
                    )
                ),
          )
        ),
    );

и результат: SliverAppBar внутри NestedScrollView SliverAppBar inside NestedScrollView

i want to get something like this, this one i made with only CustomScrollView to store SliverAppBar and SliverList.

SliverAppBar inside CustomScrollView SliverAppBar внутри CustomScrollView

...