当前位置:网站首页>A brief talk on shutter button
A brief talk on shutter button
2022-06-11 19:46:00 【antu58】
As a common component that can no longer be used ,material In the library button The components are a little strange —— There are internal and external margins that cannot be set , Let's make a simple presentation , Select several common button, Unified use Text do child, Plus a red one Container Components , Observe margin and padding.
You'll find that , except InkWell, Even if padding Set to 0, Still can not eliminate up and down padding, It's not padding Property is not valid , Instead, these buttons are constrained by the default size . This can be done through the source code and without setting child Of UI To prove .


MaterialButton Set its height property , Look at the use of source code , Is to modify the height constraint , But it cannot be modified to a certain extent , Because there are further restrictions in other places , This is what I find strange . This will cause inconvenience to the user , So one of my basic principles in designing basic components is not to interfere with the use of the outside world , For example, I made one Card Components , I will not give it a default margin.
MaterialButton(
onPressed: () {
},
// child: Text("MaterialButton"),
padding: EdgeInsets.all(0),
height: 10,
)The solution
In fact, it is the only normal component mentioned above ,Inkwell, In fact, all the above button Are further encapsulation of it , It contains click effects ( Water ripple ), And gesture recognition , And its essence is also in GestureDetector An animation layer is added on the basis of , So if you don't need animation , You can use it directly GestureDetector. A little more advanced is to create your own... Based on these two Button.
InkWell Of build Part of the source code (ink_well.dart)

Code tested
Column(children: [
SizedBox(width: double.infinity,),
addSpacer(),
InkWell(child: Text("InkWell"), onTap: () {
},).addRedBackground(),
addSpacer(),
TextButton(
onPressed: () {},
child: Text("TextButton"),
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero)
),
).addRedBackground(),
addSpacer(),
MaterialButton(
onPressed: () {
},
child: Text("MaterialButton"),
padding: EdgeInsets.all(0),
).addRedBackground(),
addSpacer(),
OutlinedButton(
onPressed: () {},
child: Text("OutlinedButton"),
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
).addRedBackground(),
],
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
),
// empty button
Column(children: [
SizedBox(width: double.infinity,),
addSpacer(),
InkWell(child: Text(""), onTap: () {
},).addRedBackground(),
addSpacer(),
TextButton(
onPressed: () {},
child: Text(""),
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero)
),
).addRedBackground(),
addSpacer(),
MaterialButton(
onPressed: () {
},
// child: Text("MaterialButton"),
padding: EdgeInsets.all(0),
).addRedBackground(),
addSpacer(),
OutlinedButton(
onPressed: () {},
child: Text(""),
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
).addRedBackground(),
],
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
)边栏推荐
- How are functional components different from class components
- 使用贝叶斯优化进行深度神经网络超参数优化
- [help] how can wechat official account articles be opened in an external browser to display the selected messages below?
- pstack和dmesg
- CMU 15-445 database course lesson 5 text version - buffer pool
- dried food! Information diffusion prediction based on sequence hypergraph neural network
- Summary 111111111111111111111
- STL application (unfinished
- Pyramid test principle: 8 tips for writing unit tests
- 图床:PicGo+腾讯云+typora
猜你喜欢

Leetcode 1992. 找到所有的农场组(可以,一次过)

RTL arbiter design

Go语言入门(六)——循环语句

Highcharts sets the histogram width, gradient, fillet, and data above the column

Programmers have changed dramatically in 10 years. Everything has changed, but it seems that nothing has changed

Google proposed the super pre training model coca, and the accuracy of fine-tuning top-1 on Imagenet reached 91%! SOTA! On multiple downstream tasks

RTL仲裁器设计

激活函数公式、导数、图像笔记

Unsupervised image classification code analysis notes of scan:learning to classify images without (1): simclr

Poj1028 web navigation
随机推荐
APB2standard_handshake_bridge 设计
Software requirements engineering review
Chrome tips - browser web page setting coding, solving the problem of web page garbled code, obtaining the latest version of charset plug-in, UTF-8 coding setting
Proficient in xmake
图床:PicGo+腾讯云+typora
Anaconda安装、Jupyter Notebook默认启动路径修改及Nbextensions插件安装
dried food! Information diffusion prediction based on sequence hypergraph neural network
Learn about random library · 1
Flutter--Button浅谈
Qubicle notes: Hello voxel
2022各大厂最新总结的软件测试宝典,看完不怕拿不到offer
【Bug解决】UnpicklingError: A load persistent id instruction was encountered, but no persistent_load.
【高精度】X进制整数加法
激活函数公式、导数、图像笔记
基于 Vue + Codemirror 实现 SQL 在线编辑器
【求助】請問如何讓微信公眾號文章在外部瀏覽器中打開後還能顯示下方的精選留言?
2022Redis7.0x版本持久化详细讲解
Hospital intelligent infusion management system source code hospital source code
Poj1028 web navigation
接口隔离原则