当前位置:网站首页>直播app源码,随着页面上下滚动自动吸顶
直播app源码,随着页面上下滚动自动吸顶
2022-04-22 15:32:00 【云豹网络科技】
直播app源码,随着页面上下滚动自动吸顶实现的相关代码
代码示例
NestedScrollView(
controller: _scrollController,
headerSliverBuilder: _headerSliverBuilder,
body: buildSliverBody(context)
)
///页面滚动头部处理
List<Widget> _headerSliverBuilder(BuildContext context, bool innerBoxIsScrolled) {
return <Widget> [
buildSliverAppBar(context)
];
}
///导航部分渲染
Widget buildSliverAppBar(BuildContext context) {
return SliverAppBar(
//当此值为true时 SliverAppBar 会固定在页面顶部
//当此值为fase时 SliverAppBar 会随着滑动向上滑动
pinned: true,
//滚动是是否拉伸图片
stretch: true,
//展开区域的高度
expandedHeight: 500,
//当snap配置为true时,向下滑动页面,SliverAppBar(以及其中配置的flexibleSpace内容)会立即显示出来,
//反之当snap配置为false时,向下滑动时,只有当ListView的数据滑动到顶部时,SliverAppBar才会下拉显示出来。
snap: false,
//阴影
elevation: 0,
//背景颜色
backgroundColor: headerWhite? Colors.white : Color(0xFFF4F5F7),
//App bar 的亮度,有白色和黑色两种主题,默认值为 ThemeData.primaryColorBrightness
brightness: Brightness.light,
//在标题左侧显示的一个控件,在首页通常显示应用的 logo;在其他界面通常显示为返回按钮
leading: IconButton(
icon: Image.network(backIcon, height: 22, width: 22,),
onPressed: (){
//TODO: 返回事件处理
}
),
//一个显示在 AppBar 下方的控件,高度和 AppBar 高度一样, // 可以实现一些特殊的效果,该属性通常在 SliverAppBar 中使用
flexibleSpace: FlexibleSpaceBar(
title: headerWhite ? Text('长津湖', style: TextStyle(
color: Color(0xFF333333),
fontWeight: FontWeight.w700,
fontSize: 17,
fontFamily: 'PingFangSC-Semibold'
),) : Text(''),
//标题居中
centerTitle: true,
background: buildAppBarBackground(context),
),
);
}
属性
const SliverAppBar({
Key key,
this.leading, //在标题左侧显示的一个控件,在首页通常显示应用的 logo;在其他界面通常显示为返回按钮
this.automaticallyImplyLeading = true,//? 控制是否应该尝试暗示前导小部件为null
this.title, //当前界面的标题文字
this.actions, //一个 Widget 列表,代表 Toolbar 中所显示的菜单,对于常用的菜单,通常使用 IconButton 来表示;对于不常用的菜单通常使用 PopupMenuButton 来显示为三个点,点击后弹出二级菜单
this.flexibleSpace, //一个显示在 AppBar 下方的控件,高度和 AppBar 高度一样, // 可以实现一些特殊的效果,该属性通常在 SliverAppBar 中使用
this.bottom, //一个 AppBarBottomWidget 对象,通常是 TabBar。用来在 Toolbar 标题下面显示一个 Tab 导航栏
this.elevation, //阴影
this.forceElevated = false,
this.backgroundColor, //APP bar 的颜色,默认值为 ThemeData.primaryColor。改值通常和下面的三个属性一起使用
this.brightness, //App bar 的亮度,有白色和黑色两种主题,默认值为 ThemeData.primaryColorBrightness
this.iconTheme, //App bar 上图标的颜色、透明度、和尺寸信息。默认值为 ThemeData().primaryIconTheme
this.textTheme, //App bar 上的文字主题。默认值为 ThemeData().primaryTextTheme
this.primary = true, //此应用栏是否显示在屏幕顶部
this.centerTitle, //标题是否居中显示,默认值根据不同的操作系统,显示方式不一样,true居中 false居左
this.titleSpacing = NavigationToolbar.kMiddleSpacing,//横轴上标题内容 周围的间距
this.expandedHeight, //展开高度
this.floating = false, //是否随着滑动隐藏标题
this.pinned = false, //是否固定在顶部
this.snap = false, //与floating结合使用
})
flexibleSpace
flexibleSpace: FlexibleSpaceBar(
//是否展示标题
title: headerWhite ? Text('长津湖', style: TextStyle(
color: Color(0xFF333333),
fontWeight: FontWeight.w700,
fontSize: 17,
fontFamily: 'PingFangSC-Semibold'
),) : Text(''),
//标题居中
centerTitle: true,
//折叠部分背景图片
background: Container(
height: 400,
width: ScreenUtil().screenWidth,
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage('https://p0.meituan.net/movie/0e81560dc9910a6a658a82ec7a054ceb5075992.jpg@464w_644h_1e_1c'),
fit: BoxFit.fill
)
),
),
)
以上就是直播app源码,随着页面上下滚动自动吸顶实现的相关代码, 更多内容欢迎关注之后的文章
版权声明
本文为[云豹网络科技]所创,转载请带上原文链接,感谢
https://yunbaozhibo.blog.csdn.net/article/details/124345114
边栏推荐
- ROS communication mechanism III - parameter server
- 【深入理解TcaplusDB技术】读取列表指定位置数据接口说明——[List表]
- Build your own web site (8)
- How to input multi line string in yaml?
- How to measure small current with oscilloscope and current probe
- Vscode handles code merge conflicts
- vscode处理代码合并冲突
- Quickly build your own wordpress blog site [play with Huawei cloud]
- TcaplusDB君 · 行业新闻汇编(三)
- Dataset之CASIA-WebFace:CASIA-WebFace 数据集的简介、安装、使用方法之详细攻略
猜你喜欢

Construction method and process of enterprise level knowledge management (km)

阿里P9手写39模块Redis核心笔记,吃透笔记我面试成功涨薪7K
理想与集度的技术之争:激光雷达究竟装哪儿更安全?

【深入理解TcaplusDB技术】示例代码——数据分批返回
![[in depth understanding of tcallusdb technology] sample code of batch reading data - [generic table]](/img/7b/8c4f1549054ee8c0184495d9e8e378.png)
[in depth understanding of tcallusdb technology] sample code of batch reading data - [generic table]

性能飙升66%的秘密:AMD 2.5万元768MB 3D缓存霄龙首次开盖

分布式任務調度平臺XXL-JOB安裝及使用

CASIA webface of dataset: a detailed introduction to the introduction, installation and use of CASIA webface dataset

Workplace PUA, five sins of managers

Magic use of solve
随机推荐
快速搭建属于你自己的WordPress博客站点【玩转华为云】
[milestone] wireguard series articles (7): creating a full mesh network using wireguard and netmaker
The GNU build system experience tutorial: Hello world example with Autoconf and automake
【深入理解TcaplusDB技术】读取列表指定位置数据接口说明——[List表]
Construction method and process of enterprise level knowledge management (km)
Overview of microservice Technology
【深入理解TcaplusDB技术】异步扫描数据示例代码——[Generic表]
【深入理解TcaplusDB技术】将数据插入到列表指定位置接口说明——[List表]
这个陀螺仪的精度太高了,还是建议禁止使用吧。
[model] state space average modeling - step down
Terraform 最佳实践:典型文件布局
【深入理解TcaplusDB技术】示例代码——异步调用接口
The GNU build system体验教程:Hello world example with Autoconf and Automake
vscode处理代码合并冲突
Terraform best practices: typical file layout
Construction method and process of enterprise level knowledge management (km)
Grafana系列文章-「译」基于 Grafana 的全栈可观察性 Demo
【深入理解TcaplusDB技术】根据部分Key字段值读取数据示例代码——[Generic表]
E. 2-Letter Strings
【深入理解TcaplusDB技术】插入数据示例代码——[Generic表]