当前位置:网站首页>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修改SQL语句优化性能
- Google Earth Engine - Error resolution of Error: Image.clipToBoundsAndScale, argument 'input': Invalid type
- 【元胞自动机】基于matlab界面聚合元胞自动机模拟【含Matlab源码 2004期】
- 更换树莓派内核
- pdb drug comprehensive database
- High dimensional Gaussian distribution basics
- 【uniCloud】云对象的应用与提升
- MYSQL master-slave replication
- Daily practice of LeetCode - Circular linked list question (interview four consecutive questions)
- 二舅
猜你喜欢
随机推荐
Euler system (euleros): upgrade Mysql
IDEA does not recognize the module (there is no blue square in the lower right corner of the module)
The kernel of the decompression process steps
【分层强化学习】HIRO:Data-Efficient Hierarchical Reinforcement Learning
MYSQL two-phase commit
机器学习初学者可以学哪些实战项目?
MYSQL Classic Interview Questions
Basic usage concepts of vim
Unity3D study notes 10 - texture array
Solve the problem that Excel opens very slowly after installing MySQL
Handwritten binary search tree and test
High dimensional Gaussian distribution basics
Modern Enterprise Architecture Framework 1
MYSQL Index Analysis
By CSDN, torn
大佬们,MySQL cdc source在增量过程中回收 replication slave 和 r
【Make YOLO Great Again】YOLOv1-v7全系列大解析(Neck篇)
MYSQL Keyword Explain Analysis
787. 归并排序
Nmap manuals - the full version