LoginSignup
3
3

More than 3 years have passed since last update.

VoidCallBackで引数あり関数を呼ぶ

Posted at

はじめに

  • Flutterでボタンが押された際に呼ぶメソッドが引数ありの場合呼べなかったので解決策メモします

なかみ

引数無しの場合であれば下記のように書くだけでいい

main.dart
...

void start(){
    ...
}

...

RaisedButton(
  onPressed: start,
  child: Text("Start", style: TextStyle(fontSize: 14)),
))

引数ありの場合

main.dart
...

void start(String title){
    ...
}

...

RaisedButton(
  onPressed: () => start("next page"),
  child: Text("Start", style: TextStyle(fontSize: 14)),
))
3
3
1

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
3
3