0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Dartで名前付きの引数をつかう

0
Posted at

関数に名前付きの引数を使わない場合

特に引数に名前をつけない場合はこんな感じで定義します

void sendMessage(String title, String message) {
...
}

呼び出す時

sendMessage('たいとる', 'めっせーじ');

関数に名前付きの引数を使う場合

引数に名前をつける場合はこんな感じで定義します

void sendMessage({String title, String message}) {
...
}

呼び出す時

sendMessage(title: 'たいとる', message: 'めっせーじ');

順番を逆にして呼び出すこともできます。

sendMessage(message: 'めっせーじ', title: 'たいとる');

呼び出し時に名前をつけて引数を渡さないと、ビルドエラーが発生します。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?