0

想在图片上头像部分浮动 ,头像有如下列表或内容,下拉时不要拉伸

CustomScrollView
  slivers
    SliverAppBar
      flexibleSpace
        background: Image
    SliverList
      CircleAvatar
CustomScrollView(
  physics: const AlwaysScrollableScrollPhysics(),
  slivers: <Widget>[
    SliverAppBar(
      floating: true,
      pinned: true,
      expandedHeight: 120.0,
      stretch: true,
      stretchTriggerOffset: 150.0,
      flexibleSpace: FlexibleSpaceBar(
        background: Image.network(indexData.banner, fit: BoxFit.cover,),
      ),
    ),
    SliverList(
      delegate: new SliverChildBuilderDelegate((BuildContext context, int index) {
        return Column(
          children: <Widget>[
            Row(
              children: <Widget>[
                Container(
                  width: 95,
                  height: 95,
                  margin: EdgeInsets.only(left: 16),
                  child: CircleAvatar(
                    backgroundImage: NetworkImage(indexData.avatar),
                    radius: 42.5,
                  ),
                  decoration: new BoxDecoration(
                      border: new Border.all(width: 5.0, color: blackLight),
                      borderRadius: new BorderRadius.all(new Radius.circular(42.5)),
                      color: blackLight
                  ),
                )
              ],
            )
          ] ,
        );
      }, childCount: 1 ),
    ),
  ],
)

slivers使用StackRenderViewport 需要一个 RenderSliv​​er 类型的子级,但收到了一个 RenderStack 类型的子级。

为什么只有SliverList、SliverFixedExtentList、SliverGrid、SliverPadding、SliverAppBar...可以在slivers中使用?

4

1 回答 1

-2

在此处输入图像描述

灵活空间:堆栈(孩子:[定位(孩子:图像(适合:BoxFit.cover,图像:NetworkImage(小部件.details,),),顶部:0,左侧:0,右侧:0,底部:0),定位(孩子:容器(高度:20,装饰:BoxDecoration(boxShadow:[BoxShadow(颜色:const Color(0x29000000),偏移量:偏移量(0,-8),blurRadius:15,),],颜色:Colors.white,borderRadius :BorderRadius.vertical(顶部:Radius.circular(50),),),),底部:-1,左:0,右:0,),],),expandHeight:450.0,),SliverList(代表:新SliverChildBuilderDelegate( (BuildContext context, int index) { return overView(); }, childCount: 1), ), ],

于 2020-11-19T15:06:32.160 回答