我想要實作的是讓父級只能點擊而不是父級的子級。假設有一個大小為 400x400 的可點擊容器,該容器的子容器是另一個大小為 200x200 的容器。
現在,如果我們觸摸第二個容器(較小的),它也是可點擊的。如何防止小容器被點擊?
我幾乎嘗試了所有方法,但我可能沒有那么好的顫振技巧,請幫助。
代碼:
InkWell(onTap: (){print('Container Clicked');},child:
Container(height: 400, width: 400, color: Colors.blue,
child: Center(child: Container(height: 200,width: 200, color: Colors.green,)),),)
uj5u.com熱心網友回復:
嘗試這個
InkWell(
onTap: (){
print('Container Clicked');
},
child: Container(
height: 400,
width: 400,
color: Colors.blue,
child: Center(
child: GestureDetector(
onTap: () {}, /// <-- locked inkwell tap
child: Container(
height: 200,
width: 200,
color: Colors.green,)
),
),
),
)
uj5u.com熱心網友回復:
我希望我答對了你的問題。如果您只想使更大的容器可點擊,這是代碼,
Stack(
children:[
InkWell(
onTap: (){
print('Container Clicked');
},
child: Container(
height: 400, width: 400,
color: Colors.blue,
),
),
Center(
child: Container(
height: 200,width: 200,
color: Colors.green,
),
),
],
),
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/315569.html
上一篇:如何使用GetStorage保存和檢索List<Map>
下一篇:如何在顫振中創建鋸齒狀邊框
