当前位置:网站首页>Flutter 页面跳转 传参,TabBar学习总结5
Flutter 页面跳转 传参,TabBar学习总结5
2022-06-10 13:39:00 【tnan2522】
Route
在Flutter中跳转页面分两种,静态路由和动态路由
静态路由Route
静态路由 是固定的, 是不能传递参数的, 在MaterialApp 组件中设置routes
import 'package:my_first_app/pages/search.dart' as search;
import './Formdata.dart' as formdata;
.....
routes: {
// routes 注册命名路由表,可以通过这个路由的key进行跳转到不同的value页面
"/from": (context) => formdata.From(),
"/search": (context) => search.Searcj(),
},
在类中设置routes 字典, 当触发事件时, 如点击按钮
onPressed: () {
Navigator.of(context).pushNamed("from");
}
它会自动的找 MaterialApp 中的 routes中的键对应的value 值, 然后进行跳转
动态路由跳转
动态路由跳转是可以携带参数进行跳转的, 在类中定义一个 Map 用键值对将 跳转路由名字和跳转的页面组件进行关联, 如
然后在 MaterialApp组件中监听 onGenerateRoute路由跳转事件,当按钮中点击事件 onPressed
发生的时候, 会调用 onGenerateRoute如图
可以在settings.arguments 中传递参数,参数可以是map类型的数据,这样就可以传递多个数据了
TabBar
TabBar 就是页面中底部tab切换组件,如
可以将属于同一页面中的不同数据进行分类
TabBar 是在 DefaultTabController组件中的,
lenght 设置tabbar 组件的个数, 如果在bottom中 Widget列表个数没有符合这个数的话,那么就会出错
而 在TabBar中body的属性也是特殊的组件 TabBarView组件, 在children 中编写不同TabBar页面展示的组件, 当发生点击TabBar时, 它会自动的获取children中的对应下标的组件数据进行展示

边栏推荐
- buuctf [Discuz]wooyun-2010-080723
- 解决安装gerapy的时候报错:ERROR: Cannot uninstall ‘certifi‘. It is a distutils installed project...
- [Netease Yunxin] in depth analysis of the design of "circle group" message system | series of articles on "circle group" technology
- 如何定位游戏发热问题
- [cloud computing] what is the relationship between a multi cloud management platform and a public cloud?
- buuctf [Jupyter]notebook-rce
- 【C语言】指针函数与函数指针、数组函数
- CentOS Linux 已死!Oracle Linux 可能是它的更好替代品
- [Multisim Simulation] differential amplifier circuit 2
- 5.8G微波雷达模块使用,5.8G微波雷达模块工作原理和介绍
猜你喜欢
![[笔记]Windows安全之《三》Shellcode 补充之 Get-InjectedThread脚本搭建环境及其使用](/img/b4/f7838a7e12379190e2bc9b869839f0.png)
[笔记]Windows安全之《三》Shellcode 补充之 Get-InjectedThread脚本搭建环境及其使用

智慧校园安全通道及视频监控解决方案

Z-Wave ecosystem status report in 2022

软件智能:aaas系统 度量衡及文法的形式规则

618. How to prepare for the great promotion
![[note] the environment for setting up get injectedthread script supplemented by shellcode in Windows Security III and its use](/img/b4/f7838a7e12379190e2bc9b869839f0.png)
[note] the environment for setting up get injectedthread script supplemented by shellcode in Windows Security III and its use

大厂必备的40个方法论

架构实战营 第 6 期 模块八课后作业

Recommend an efficient IO component - okio
![[operation tutorial] how to correctly use the Hikvision demo tool to configure the channel to go online?](/img/2f/b4d18ac1f030f7678e6f0b59c61291.png)
[operation tutorial] how to correctly use the Hikvision demo tool to configure the channel to go online?
随机推荐
CL210OpenStack操作的故障排除--常见核心问题的故障排除
net core天马行空系列-可用于依赖注入的,数据库表和c#实体类互相转换的接口实现
Leetcode 829. Sum of continuous integers
net core天马行空系列-可用于依赖注入的,数据库表和c#实体类互相转换的接口实现
Application analysis of key recording and playing of wt2003h4-16s voice chip
[Huang ah code] Why is php7 twice as fast as PHP5?
解决VMware Workstation安装VMware Tools显示灰色的办法
Meetup review how Devops & mlops solve the machine learning dilemma in enterprises?
数码管驱动芯片+语音芯片的应用场景介绍,WT588E02B-24SS
[FAQ] summary of common problems and solutions during the use of rest API interface of sports health service
TabLayout 使用详解(修改文字大小、下划线样式等)
【笔记】C语言数组指针、结构体+二维数组指针小记
常识,神经元数量,小鼠的脑内神经元大约在7000万个、人类约有860亿个
Tablayout usage details (modify text size, underline style, etc.)
3. web page development tool vs Code
十款好用跨浏览器测试工具分享,好物值得收藏
WT2003H4-16S 语音芯片按键录音及播放应用解析
苹果生产线迁离,说明5G工业互联、智能制造对中国制造帮助有限
618. How to prepare for the great promotion
Google Earth engine (GEE) -- batch download of DEM using MODIS leaf area index image mask