当前位置:网站首页>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
边栏推荐
- test
- Four ways the Metaverse is changing the way humans work
- 软考高级系统架构设计师系列之:信息系统基础知识
- 情人节浪漫3D照片墙【附源码】
- Solve the problem that when IDEA creates a new file by default, right-click, new, there is no XML file
- Beijing suddenly announced that yuan universe big news
- [Data analysis] Based on matlab GUI student achievement management system [including Matlab source code 1981]
- Fat interface in JQESAP system
- 【Make YOLO Great Again】YOLOv1-v7全系列大解析(Neck篇)
- Game Security 03: A Simple Explanation of Buffer Overflow Attacks
猜你喜欢
![[Data analysis] Based on matlab GUI student achievement management system [including Matlab source code 1981]](/img/65/b84443b98c28d2728e9ae44b1294fb.jpg)
[Data analysis] Based on matlab GUI student achievement management system [including Matlab source code 1981]

HIRO: Hierarchical Reinforcement Learning 】 【 Data - Efficient Hierarchical Reinforcement Learning

IDEA does not recognize the module (there is no blue square in the lower right corner of the module)

二舅

解决IDEA默认情况下新建文件时,右击,new,没有XML文件的问题

The fledgling Xiao Li's 114th blog project notes: Wisdom cloud intelligent flower watering device combat (3) - basic Demo implementation

RTL8762DK WDG (six)

IDEA 找不到或无法加载主类 或 Module “*“ must not contain source root “*“ The root already belongs to module “*“

Solve the problem that Excel opens very slowly after installing MySQL

Summary of JVM interview questions (continuously updated)
随机推荐
This map drawing tool is amazing, I recommend it~~
Google Earth Engine - Error resolution of Error: Image.clipToBoundsAndScale, argument 'input': Invalid type
how to edit the table of contents of an epub ebook
机器学习应该如何入门?
Academicians of the two academies speak bluntly: Don't be superstitious about academicians
项目越写越大,我是这样做拆分的
MYSQL query interception optimization analysis
Ordinary users cannot access HGFS directory
The fledgling Xiao Li's 112th blog project notes: Wisdom cloud intelligent flower watering device actual combat (1) - basic Demo implementation
[Data analysis] Based on matlab GUI student achievement management system [including Matlab source code 1981]
SC7A20 (Silan Micro-Accelerometer) Example
Flink 部署和提交job
高维高斯分布基础
Take you to experience a type programming practice
软考高级系统架构设计师系列之:信息系统基础知识
Basic usage concepts of vim
Summary of JVM interview questions (continuously updated)
lua entry case combat 123DIY
Chinese version of Pylint inspection rules
RTL8762DK RTC (5)