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?

【Flutter】WidgetにTapイベントを設定する

Last updated at Posted at 2025-10-16

やりたいこと

  • 任意のWidgetにタップイベントを設定する。
  • TitleListComponentにタップイベントを設定してみる。
title_list_view.dart
TitleListComponent(cover: cover[index-1]);

解決策

  • GestureDetectorを用いる
title_list_view.dart
return GestureDetector(
    onTap: () {
        // do something
    },
    child: TitleListComponent(cover: cover[index-1]),
);

構文

title_list_view.dart
return GestureDetector(
    onTap: () {
        // ここでタップイベントを定義します
    },
    child://ここにどのWidgetを押したらタップイベントを発火させたいかを書きます,
);
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?