当前位置:网站首页>Dart 命名参数语法
Dart 命名参数语法
2022-08-01 02:45:00 【小公鸡卡哇伊呀~】
对于以下代码:
void debugger(String message, int lineNum) {
// ...
}
调用时必须提供两个参数:
debugger('A bug!', 55);
如果将参数改为命名参数,则参数变为可选:
void debugger({
String message, int lineNum}) {
// ...
}
调用:
debugger(message: 'A bug!', lineNum: 44);
类的构造函数参数也可以使用这种语法。
如果一个函数参数很多,比如,有10个,使用位置参数语法时,必须记住什么位置是什么参数,十分麻烦,但是由于命名参数使用名称,参数的位置顺序变得无关紧要,从而避免了这个问题。
https://flutterbyexample.com/lesson/function-arguments-default-optional-named
边栏推荐
猜你喜欢

解决安装MySQL后,Excel打开很慢的问题

Flink 部署和提交job

How to download the Keil package

【数据分析】基于matlab GUI学生成绩管理系统【含Matlab源码 1981期】

RTL8762DK Lighting/LED (3)

how to edit the table of contents of an epub ebook
![leetcode: 1648. Color ball with decreasing sales value [Boundary find by two points]](/img/b9/7bd33bd981ace25e3bbfc7be9117ff.png)
leetcode: 1648. Color ball with decreasing sales value [Boundary find by two points]

Compiled on unbutu with wiringPi library and run on Raspberry Pi

MYSQL master-slave replication

HCIP(15)
随机推荐
Summary of JVM interview questions (continuously updated)
When opening a MYSQL table, some can display editing, some do not, how to set.
sqlserver cannot connect remotely
leetcode:1562. 查找大小为 M 的最新分组【模拟 + 端点记录 + 范围合并】
By CSDN, torn
Google Earth Engine - Error resolution of Error: Image.clipToBoundsAndScale, argument 'input': Invalid type
设备树——dtb格式到struct device node结构体的转换
手写二叉查找树及测试
Modern Enterprise Architecture Framework 1
pdb药物综合数据库
gateway gateway cross domain
Euler system (euleros): upgrade Mysql
WebApi 打个Attribute 统一处理异常
Chinese version of Pylint inspection rules
被 CSDN,伤透了心
修改Postman安装路径
TCP协议详解
Solve the problem that when IDEA creates a new file by default, right-click, new, there is no XML file
leetcode: 1562. Find latest grouping of size M [simulation + endpoint record + range merge]
链式编程、包、访问权限