当前位置:网站首页>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 itvisible
to 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的size
properties 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
边栏推荐
- 网络原理 基础知识
- Fabric 私有数据案例
- Talk about the construction of the performance test environment
- 【SemiDrive源码分析】【MailBox核间通信】43 - 基于Mailbox IPCC RPC 实现核间通信(代码实现篇)
- [VMWARE--Shared files]
- 裁员趋势下的大厂面试:“字节跳动”
- sublime 背景透明度以及列编辑
- LeetCode 2348. Number of all-zero subarrays
- [QNX Hypervisor 2.2用户手册]9.12 预留
- js中原型链的理解,原型链解决的是什么问题?
猜你喜欢
MPLS VPN跨域-optionC2
CMake Tutorial Tour (1)_Basic starting point
[Microservice~Nacos] Nacos service provider and service consumer
视觉系统设计实例halcon-winform-11.菜单折叠与展示
Towards Better Understanding of Self-Supervised Representations / Q-Score
Google浏览器打开axure产品原型的解决方案
flutter学习之widget的显示和隐藏
推荐系统:特征工程、常用特征
sqlserver 多行合并成一行
my creative day
随机推荐
什么专业越老越吃香?
msyql set names 字符转换处理
Running a Fabric Application
记一次搭建conda虚拟环境
基于低能耗自适应聚类层次结构(LEACH)(Matlab代码实现)
JS develops 3D modeling software
【微服务~Nacos】Nacos之配置中心
[VMWARE--Shared files]
Graphical LeetCode - 593. Valid Squares (Difficulty: Moderate)
Leetcode69. x 的平方根
机械设备制造企业如何借助ERP系统,解决成本核算难题?
SSM整合案例
SSM integration case
实习经历梳理
Postgresql daily operation and maintenance skills, suitable for beginners
Google浏览器打开axure产品原型的解决方案
exness: U.S. GDP shrinks, yen bounces back
LeetCode 2342. 数位和相等数对的最大和
Fabric Private Data Case
数据流图、数据字典