flutterperformancegesturedetectorsingle-responsibility-principleflutter-text-button

Which is lighter in Flutter: GestureDetector or TextButton?


After watching the widget of the week about GestureDetectors they seem filled with many callback options my average widgets won't ever need. Is there any difference in performance compared with the basic TextButton ? Doesn't the GestureDetector infringe the single responsibility principle ?

When should I use either ?

I couldn't perceive any difference in simple apps with a few buttons.


Solution

  • With respect to performance, GestureDetector is a better option since it primarily handles touch events and doesn't contain any styling functions like TextButton

    If you're concerned about styling use textfield else gesture detector.