当前位置:网站首页>The flutter slivereappbar is fully parsed. All the effects you want are here!
The flutter slivereappbar is fully parsed. All the effects you want are here!
2022-06-28 00:55:00 【InfoQ】



What is? SliverAppBar
CollapsingToolbarLayoutCommon properties
const SliverAppBar({
Key key,
this.leading,// The icon or text on the left , Mostly return arrows
this.automaticallyImplyLeading = true,// No, leading by true When , Default return arrow , No, leading And for false, Is displayed title
this.title,// title
this.actions,// Operation to the right of the title
this.flexibleSpace,// It can be understood as SliverAppBar Background content area
this.bottom,//SliverAppBar Bottom area of
this.elevation,// shadow
this.forceElevated = false,// Show shadows
this.backgroundColor,// The background color
this.brightness,// Status bar theme , Default Brightness.dark, Optional parameters light
this.iconTheme,//SliverAppBar Icon theme
this.actionsIconTheme,//action Icon theme
this.textTheme,// Text theme
this.primary = true,// Whether to display below the status bar ,false Will occupy the height of the status bar
this.centerTitle,// Is the title centered
this.titleSpacing = NavigationToolbar.kMiddleSpacing,// Title horizontal spacing
this.expandedHeight,// Merge height , The default is the height of the status bar plus AppBar Height
this.floating = false,// Whether it is suspended during sliding
this.pinned = false,// Whether the title block is fixed
this.snap = false,// coordination floating Use
})
The basic effect

return Scaffold(
body: new CustomScrollView(
slivers: <Widget>[
new SliverAppBar(
title: Text(" title "),
expandedHeight: 230.0,
floating: false,
pinned: true,
snap: false,
),
new SliverFixedExtentList(
itemExtent: 50.0,
delegate: new SliverChildBuilderDelegate(
(context, index) => new ListTile(
title: new Text("Item $index"),
),
childCount: 30,
),
),
],
),
);
add to leading
leading: new IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {},
),

add to actions
actions: <Widget>[
new IconButton(
icon: Icon(Icons.add),
onPressed: () {
print(" add to ");
},
),
new IconButton(
icon: Icon(Icons.more_horiz),
onPressed: () {
print(" more ");
},
),
],

Slide title up effect
flexibleSpace: new FlexibleSpaceBar(
title: new Text(" Title "),
centerTitle: true,
collapseMode: CollapseMode.pin,
),

Background picture immersive
pubspec.yaml assets:
- images/a.jpg
flexibleSpace: new FlexibleSpaceBar(
background: Image.asset("images/a.jpg", fit: BoxFit.fill),
),

Demonstration of various sliding effects
- floating: false, pinned: true, snap: false:

- floating: true, pinned: true, snap: true:

- floating: false, pinned: false, snap: false:

- floating: true, pinned: false, snap: false:

- Whether the title bar slides with it
- When sliding up ,SliverAppBar Whether to directly slide up or merge first and then slide up .
- When you pull it down ,SliverAppBar Whether to pull it down directly or pull it down first and then unfold it .
add to TabBar
var _tabs = <String>[];
_tabs = <String>[
"Tab 1",
"Tab 2",
"Tab 3",
];
/// Add TabBar
DefaultTabController(
length: _tabs.length, // This is the number of tabs.
child: NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
// These are the slivers that show up in the "outer" scroll view.
return <Widget>[
SliverOverlapAbsorber(
handle:
NestedScrollView.sliverOverlapAbsorberHandleFor(context),
child: SliverAppBar(
leading: new IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {},
),
title: const Text(' title '),
centerTitle: false,
pinned: true,
floating: false,
snap: false,
primary: true,
expandedHeight: 230.0,
elevation: 10,
// Show shadows , Direct value innerBoxIsScrolled, Expand not to show shadows , After merging, it will display
forceElevated: innerBoxIsScrolled,
actions: <Widget>[
new IconButton(
icon: Icon(Icons.more_horiz),
onPressed: () {
print(" more ");
},
),
],
flexibleSpace: new FlexibleSpaceBar(
background: Image.asset("images/a.jpg", fit: BoxFit.fill),
),
bottom: TabBar(
tabs: _tabs.map((String name) => Tab(text: name)).toList(),
),
),
),
];
},
body: TabBarView(
// These are the contents of the tab views, below the tabs.
children: _tabs.map((String name) {
//SafeArea One suitable for liuhaiping widget
return SafeArea(
top: false,
bottom: false,
child: Builder(
builder: (BuildContext context) {
return CustomScrollView(
key: PageStorageKey<String>(name),
slivers: <Widget>[
SliverOverlapInjector(
handle:
NestedScrollView.sliverOverlapAbsorberHandleFor(
context),
),
SliverPadding(
padding: const EdgeInsets.all(10.0),
sliver: SliverFixedExtentList(
itemExtent: 50.0, //item Height or width , Depending on the sliding direction
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return ListTile(
title: Text('Item $index'),
);
},
childCount: 30,
),
),
),
],
);
},
),
);
}).toList(),
),
),
),

边栏推荐
- Efficient supplier management in supply chain
- .mp4视频测试地址
- Summary of wuenda's machine learning course (14)_ Dimensionality reduction
- Leetcode 720. 词典中最长的单词(为啥感觉这道题很难?)
- How many securities companies can a person open an account? Is it safe to open an account
- Is it reliable to invest in exchange traded ETF funds? Is it safe to invest in exchange traded ETF funds
- 投资场内ETF基金是靠谱吗,场内ETF基金安全吗
- Mysql database tourism management system_ Jsp+mysql tourism management system based on SSM [easy to understand]
- Electron window background transparent borderless (can be used to start the page)
- Is it safe for Xiaobai in the stock market to open an account on the Internet?
猜你喜欢

Flutter SliverAppBar全解析,你要的效果都在这了!

为什么要选择不锈钢旋转接头

Taro--- day2--- compile and run

云厂商为什么都在冲这个KPI?

Leetcode 720. The longest word in the dictionary
![[untitled]](/img/15/21020badab0d70450ccfb71f49da8a.png)
[untitled]
Latest MySQL advanced SQL statement Encyclopedia

吴恩达《机器学习》课程总结(13)_聚类

Hcip/hcie Routing & Switching / datacom Reference Dictionary Series (19) comprehensive summary of PKI knowledge points (public key infrastructure)

每次启动项目的服务,电脑竟然乖乖的帮我打开了浏览器,100行源码揭秘!
随机推荐
Mongodb- install a mongodb database locally on the windows computer
现在网上开股票账户安全吗?选择上市券商,最快8分钟开户成功
[Reading Abstract] what is wrong with English Reading Teaching in schools-- Empiricism and the PK of cognitive science
MATLAB basic function length function
剑指 Offer 65. 不用加减乘除做加法
[读书摘要] 学校的英文阅读教学错在哪里?--经验主义和认知科学的PK
Leetcode 720. 词典中最长的单词(为啥感觉这道题很难?)
Promise是什么
Deployment and test of crtmp live video server
炼金术(8): 开发和发布的并行
剑指 Offer 61. 扑克牌中的顺子
快速掌握grep命令及正则表达式
TIME_WAIT过多的解决办法
炼金术(1): 识别项目开发中的ProtoType、Demo、MVP
lodash实现防抖和节流功能及原生实现
Efficient supplier management in supply chain
从小到大为何一谈学习就愁眉苦脸
#795 Div.2 D. Max GEQ Sum 单调栈
RNA-seq入门实战(一):上游数据下载、格式转化和质控清洗
免费、好用、强大的开源笔记软件综合评测