flutter - 如何制作动态 Appbar 标题?
解决方案
在 Scaffold 内部,您应该只使用 body 而不是 appbar,并使用 CustomScrollView 作为 body。对于您的 CustomScrollView,您应该使用需要小部件列表(SliverAppBar 和 SliverList)的 Sliver。SliverList 是您的可滚动内容,SliverAppBar 是您想要的 Appbar。
Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
expandedHeight: 300,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
title: Text('the title of appbar'),
background: Image.network(
an image url,
fit: BoxFit.cover,
),
),
),
),
SliverList(
delegate: SliverChildListDelegate([
your scorrable content. make sure your content is scrollable.
]),
),
],
),
);
推荐阅读
- python - 绘制 vtk 的轮廓。带有 Python-vtk 模块的文件(来自 OpenFOAM)
- excel - python panas to_excel 设置单元格背景颜色
- javascript - 有条件地传递键值对不起作用
- chef-infra - 使用 Chef 从 Web 位置安装远程 zip
- c# - 如何让 BLE 程序调用 ValueChanged 三次?
- github-actions - 如何使用 Github Actions 推送 npm 版本?
- amazon-web-services - 为 Apache Airflow [MWAA] 创建 Apache 托管工作流:INCORRECT_CONFIGURATION
- python - 使用 mediapipe 库时是否可以不显示视频源?
- swift - Swift MobileVLCKit 如何设置 UserAgent?
- azure-virtual-network - 是否可以使私有主机名与 Azure Web 应用程序中的公共主机名相同?