Button မဟုတ်တဲ့ Container, Image, Card, Icon စတဲ့ widget တွေကို user interaction ရချင်ရင် GestureDetector နဲ့ wrap လုပ်နိုင်ပါတယ်။ ဥပမာ product card ကို tap လိုက်ရင် detail page သို့သွားတာ၊ image ကို double tap လုပ်ရင် favorite ဖြစ်တာတွေမှာအသုံးများပါတယ်။
dart
GestureDetector(
onTap: () {
print('Card tapped');
},
onLongPress: () {
print('Card long pressed');
},
child: Container(
width: 180,
padding: const EdgeInsets.all(18),
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.circular(14),
),
child: const Center(
child: Text('Tap this card'),
),
),
)You should see
အစိမ်းရောင် card ပေါ်လာပြီး tap သို့မဟုတ် long press လုပ်တဲ့အခါ console မှာ message ပေါ်ပါမယ်။နောက်တစ်ဆင့်
User ကစာရိုက်ထည့်နိုင်တဲ့ TextField နဲ့ form input ကိုဆက်သင်ပါ။