LoginSignup
15

More than 5 years have passed since last update.

posted at

updated at

【Flutter】任意のWidgetにクリックイベントをつける

Flutterアプリで任意のWidgetにクリックイベントをつけるやり方メモです。

結論

GestureDetector widgetを使う。

サンプルコード

GestureDetector(
  onTap: () {
    print("onTap called.");
  },
  child: Text("foo"),
),

環境

  • Flutter 0.1.5
  • Dart 2.0.0-dev.28.0

Link

user interface - Flutter - Container onPressed? - Stack Overflow
https://stackoverflow.com/questions/43692923/flutter-container-onpressed

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
What you can do with signing up
15