mardi 20 avril 2021

Create a custom button in Flutter

I would like to make a custom checkbox button with rounded corners.

Because I wasn't able to do it with a CheckBox widget, I simply created a container with rounded corners (and some styling depending on whether the "value" is true) and wrapped it in InkWell.

  • InkWell
  • Container

The problem is that the checkbox (container) is quite small and you have to tap precisely on the Container. When you use CheckBox or any other button, there is some tolerance (meaning that you can click slightly off the button). How can I achieve this with InkWell?

The only idea I have is to wrap the Container in Padding first:

  • InkWell
  • Padding
  • Container

Is this the only solution, or is there another way of making a "button" with InkWell, where the onTap function will execute even if you don't touch the button precisely?




Aucun commentaire:

Enregistrer un commentaire