Flutter的FlexibleSpaceBar

  1. FlexibleSpaceBar
// FlexibleSpaceBar
class FlexibleSpaceBarDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return NestedScrollView(
        headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
          return <Widget>[
            SliverAppBar(
              // 展开高度
              expandedHeight: 250.0,
              // 是否随着滑动隐藏标题
              floating: true,
              // 是否固定在顶部
              pinned: true,
              // 可折叠的应用栏目
              flexibleSpace: FlexibleSpaceBar(
                centerTitle: true,
                title: Text('可折叠的标题', style: TextStyle(color: Colors.white),),
                background: Image.network('https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2288748976,1582581638&fm=26&gp=0.jpg', fit: BoxFit.cover,),
              ),
            )
          ];
        },
        body: Center(
          child: Text('向上提拉,查看效果'),
        )
    );
  }
}
  1. 图片展示
    在这里插入图片描述
    在这里插入图片描述
Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐