当前位置:网站首页>The display and hiding of widgets for flutter learning
The display and hiding of widgets for flutter learning
2022-07-30 01:50:00 【GY-93】
flutter学习之widget的显示和隐藏
在IOS的开发中,We hide and show controls, 只需要设置hidden属性, 因为是View的一个基本属性,但是在flutterThere is indeed no direct attribute for you to set during development, flutterIn all thingswidget的原则.所以flutterwant to achievewidget显示和隐藏,也需要通过widget来实现.
1、Visbility组件
Widget getWidget(bool show) {
return Visibility(
child: const Text('VisibilityControls showing and hiding of controls'),
// 设置是否可见:true:可见 false:不可见
visible: show,
);
}
在需要隐藏的wdiget外层包裹Visbility组件, Then pass the properties in itvisibleto control the showing and hiding of components,true:可见, flase: 不可见
注意: VisbilityComponents are hidden and do not preserve spatial positions, Its corresponding event will also not respond
- Introduction of other properties:


2、Offstage组件
Widget getWidget2(bool show) {
return Offstage(
// 设置是否可见:true:不可见 false:可见
offstage: !show,
child: Text('offstageControls showing and hiding of controls'),
);
}
Offstage通过其中offstage属性来控制,Whether the contents of its package are visible, true:不可见, false: 可见刚好与Visbility组件中的visible效果相反
**注意:OffstageThe control component is hidden and does not preserve the spatial position,Its corresponding event will also not respond.如果Offstage 和 Positioned 一起使用,要把 Offstage 放Positioned里面,包裹 Positioned 会出现问题 **
3、Opacity组件
Widget getWidget3(bool show) {
return Opacity(
opacity: show ? 1 : 0,
child: Text('OpacityControls showing and hiding of controls'),);
}
OpacityComponent he passes its propertiesopacity来控制,This property is notbool类型而是 double类型,类似IOSTransparency property in , when you set the value to 1时,表示完全显示, 值为0时,表示隐藏, [0-1]中间的某个值, 那么widgetThe display level corresponds to the value you set.
注意: opacity设置0时,本质上把widgetThe transparency is set to fully transparent,看不见,But the space didn't disappear,And also occupy the corresponding position,The corresponding click event will also respond
4、 通过组件的size控制
Widget getWidget4(bool show) {
return Container(
color: Colors.red,
height: show ? 50 : 0,
child: Text('sizeControls showing and hiding of controls'),
);
}
通过外层widget的sizeproperties to hide and show controls
5、Empty component placeholder method
Widget getWidget5(bool show) {
return show ? Text("Empty component placeholder method"): Container();
}
Placed by an empty component,To achieve the purpose of showing and hiding
边栏推荐
- [Microservice~Nacos] Configuration Center of Nacos
- npm ERR! code ENOTSUP npm ERR! notsup Unsupported engine for [email protected]: wanted: {“n
- go 双向流模式
- 网络原理 基础知识
- 微信小程序开发之图片压缩方案
- OSPF shamlink 解决后门链路问题
- SSM integration case
- 泰克Tektronix示波器软件TDS210|TDS220|TDS224上位机软件NS-Scope
- 经济衰退时期的对比:如今更像历史上的哪段时期?
- postgresql日常运维技能,适合初学者
猜你喜欢

日期时间存入数据库会差一天?

MPLS VPN跨域-optionC2

「MySQL」- 基础增删改查
![[Microservice~Nacos] Configuration Center of Nacos](/img/c3/9d8fb0fd49a0ebab43ed604f9bd1cc.png)
[Microservice~Nacos] Configuration Center of Nacos

my creative day

【LeetCode每日一题】——872.叶子相似的树

SwiftUI SQLite Database Storage Tutorial Collection (2022 Edition)

Tibetan Mapping

错误:“filesystem“ 不是 “std“ 的成员

Recommendation system: collection of user "behavioral data" [use Kafka and Cassandra to process data] [if it overlaps with business data, it also needs to be collected independently]
随机推荐
exness: U.S. GDP shrinks, yen bounces back
【LeetCode每日一题】——404.左叶子之和
气路旋转连接器怎么用
泰克Tektronix示波器软件TDS520|TDS1001|TDS1002上位机软件NS-Scope
mysql error is too long for user name (should be no longer than 16)
Talk about the construction of the performance test environment
[机缘参悟-53]:《素书》-2-俊、豪、杰[正道章第二]
【LeetCode每日一题】——230.二叉搜索树中第K小的元素
接口测试自动化后起之秀-YApi接口管理平台
npm ERR! code ENOTSUPnpm ERR! notsup Unsupported engine for [email protected]: wanted: {“n
泰克Tektronix示波器软件TDS210|TDS220|TDS224上位机软件NS-Scope
What majors become more popular the older they get?
神经网络迭代次数的一个近似关系
LeetCode / Scala - 无重复字符最长子串 ,最长回文子串
小白必看|不用编程的labview,ATECLOUD完全满足你的需求
绘制热度图、频谱图、地形图、colormap
Typora transparent background image
Validation Framework-01
05.script_setup中的私有属性
CMake Tutorial 巡礼(0)_总述