3
2

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.

FlutterでListViewの子要素GoogleMapがタップに反応しない場合の対処方法

Last updated at Posted at 2019-12-13

#結論

import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

ListView(
  children: <Widget>[
    GoogleMap(
      gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
        Factory<OneSequenceGestureRecognizer>(
          () => EagerGestureRecognizer(),
        ),
      ].toSet(),
    ),
  ],
)

引用:https://stackoverflow.com/questions/54280541/google-map-in-flutter-not-responding-to-touch-events

#何でこれで動くのか
EagerGestureRecognizerクラスの解説を読む。

(原文)
A gesture recognizer that eagerly claims victory in all gesture arenas.
(意訳)
この GestureRecognizer は全 gesture のいる闘技場の中でも特に熱心に勝利を主張します。
https://api.flutter.dev/flutter/gestures/EagerGestureRecognizer-class.html

この文章書いた人、何かキメてたんですかね????
Eager が熱心という意味らしい。
要するにはユーザータップ時に複数の操作可能オブジェクトがあった場合に、
この Gesture が紐付けられたWidgetが最優先で反応するみたいです。
つまり、デフォルトではListViewのほうが優先度高いんですね……

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?