-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
“透明组件” 只是表述的不可见组件,容易引起误解!适当的表述可以是:命中测试失败(hitTest)的组件,如果透明组件hitTest成功,translucent 与 opaque 的特性将无效!比如使用#DecoratedBox# 来包装子组件,设置透明度为0,也是不可见,反例如下,修改此节translucent 测试代码为:
Stack(
children: [
Listener(
child: ConstrainedBox(
constraints: BoxConstraints.tight(Size(300.0, 200.0)),
child: DecoratedBox(
decoration: BoxDecoration(
color: Color.fromARGB(255, 255, 1, 1))),
),
onPointerDown: (event) => print("down0"),
// behavior: HitTestBehavior.opaque,
),
Listener(
child: ConstrainedBox(
constraints:
BoxConstraints.tight(Size(200.0, 100.0)),
child: DecoratedBox(
decoration: BoxDecoration(
color: Color.fromARGB(0, 0, 0, 0)),
child: Center(
child: Text("左上角200*100范围内非文本区域点击"),
),
)),
onPointerDown: (event) => print("down1"),
behavior: HitTestBehavior.translucent //放开此行注释后可以"点透"
)
],
),
Activity
ghost commentedon Jan 2, 2020
赞同,我也是在这里纠结了很久。