Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What, When and How to use MaterialTapTargetSize in flutter

Tags:

flutter

dart

I am new to flutter. While I am wandering through flutter docs. I found MaterialTapTargetSize in Button's property. The docs made me confused.

So I want to know

  1. what is the usage of MaterialTapTargetSize property?
  2. When to use?
  3. How to use?

simple English that would be better for me. Thank you

like image 333
archmedis Avatar asked Sep 11 '25 23:09

archmedis


1 Answers

  1. The MaterialTapTargetSize property of a widget set an area around a widget to catch gestures etc. The area around the checkbox below is an example.

checkbox with taptarget size

  1. An instance would be when you want this

this

but you have this

enter image description here

Notice the space around the checkbox is preventing it from aligning to the start as the TextField above it.

  1.  Checkbox(
     value: model.checkboxValue,
     onChanged: (onChanged) {
     model.onCheckboxChecked(onChanged);
     },
     materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
     ),
    

Note that this reduces the space around the checkbox, it doesn't remove it fully.

like image 100
Quwaysim Avatar answered Sep 14 '25 13:09

Quwaysim