GestureDetector的behavior
有三个类型
enum HitTestBehavior {
/// Targets that defer to their children receive events within their bounds
/// only if one of their children is hit by the hit test.
deferToChild,
/// Opaque targets can be hit by hit tests, causing them to both receive
/// events within their bounds and prevent targets visually behind them from
/// also receiving events.
opaque,
/// Translucent targets both receive events within their bounds and permit
/// targets visually behind them to also receive events.
translucent,
}
默认是deferToChild,只有当children可以接收点击事件才能响应点击。
原因:
业务场景是点击textfield跳转到新页面,所以套一层GestureDetector来响应,然后将TextField的enabled
设置为false,所以默认情况下响应不了点击。解决方法:
将GestureDetector的behavior
属性修改为behavior: HitTestBehavior.opaque
即可。