繁体   English   中英

添加 carousel_slider Down of SliverAppBar flutter

[英]add carousel_slider Down of SliverAppBar flutter

我尝试在 SliverAppBar 中添加 carousel_slider

需要在 contentView 之前添加静态滑块

   body: Builder(
            builder: (BuildContext context) {
              return RefreshIndicator(
                child: CustomScrollView(
                  controller: _scrollController,
                  slivers: <Widget>[
                    SliverAppBar(
                      primary: false,
                      expandedHeight: 75,
                      backgroundColor: Color(0xFFf4eedd),
                      floating: true,
                      actions: <Widget>[
                        Container(
                          width: MediaQuery.of(context).size.width,
                          decoration: BoxDecoration(
                              image: DecorationImage(
                                  image: AssetImage('images/banner.png'),
                                  fit: BoxFit.fitWidth)),
                        ),
                      ],
                    ),
                    contentView,
                  ],
                ),
                onRefresh: () async {
                  this._pageLoadController.reset();
                  await Future.value({});
                },
              );
            },
          ));

contentView 这是一个来自 json 向下滚动的项目

我用 SliverToBoxAdapter 做

  body: Builder(
    builder: (BuildContext context) {
      return RefreshIndicator(
        child: CustomScrollView(
          controller: _scrollController,
          slivers: <Widget>[
            SliverAppBar(
              primary: false,
              expandedHeight: 75,
              backgroundColor: Color(0xFFf4eedd),
              floating: true,
              actions: <Widget>[
                Container(
                  width: MediaQuery.of(context).size.width,
                  decoration: BoxDecoration(
                      image: DecorationImage(
                          image: AssetImage('images/banner.png'),
                          fit: BoxFit.fitWidth)),
                ),
              ],
            ),
            SliverToBoxAdapter(
                child: Container(
              height: 100.0,
              child: ListView.builder(
                scrollDirection: Axis.horizontal,
                itemCount: 10,
                itemBuilder: (context, index) {
                  return Container(
                    width: 100.0,
                    child: Card(
                      child: Text('data'),
                    ),
                  );
                },
              ),
            )),
            contentView,
          ],
        ),
        onRefresh: () async {
          this._pageLoadController.reset();
          await Future.value({});
        },
      );
    },
  )

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM