Skip to content

Software Development at Program Tom LTD

Place for coding, programming, development and software in general.

Menu
  • Blog
  • PDF Booklets
  • Dev Utils & Content
  • Java Spring Boot Or Web Apps
  • English
    • български
    • English
    • Español
    • Português
    • हिन्दी
    • Русский
    • Deutsch
    • Français
    • Italiano
    • العربية
  • About Us
  • Flutter Apps
Menu
Example of Flutter InkWell vs Button vs Material vs GestureDetector

Flutter InkWell vs Button vs Material vs GestureDetector

Posted on January 1, 2025January 1, 2025 by Toma Velev

There are several widgets to code Button behaviour in Flutter, besides the variations of Button, there are InkWell, Material & GestureDetector.

1. Material widgets

  • Material: A widget that provides a material design background, but without actual behaviour
  • MaterialButton: A button with a material design background with present ripple effect.
// Material (Material)
Material(
  elevation: 10,
  child: Container(
    width: 100,
    height: 50,
    color: Colors.blue,
  ),
)

2. Button widgets

  • ElevatedButton: A material design button with elevation.
  • TextButton: A simple text-based button.
  • OutlinedButton: A material design button with an outline.
  • FloatingActionButton: A circular button that hovers over the screen.
// ElevatedButton (Button)
ElevatedButton(
  onPressed: () {},
  child: Text('Click me'),
)

2. Ink widgets

  • InkWell: A widget that responds to touches by displaying an ink splash.
  • InkResponse: Similar to InkWell, but with more customization options.
// InkWell (Ink)
InkWell(
  onTap: () {},
  child: Container(
    width: 100,
    height: 50,
    color: Colors.blue,
  ),
)

4. Gesture widgets

  • GestureDetector: A widget that detects gestures, such as taps and swipes, but does NOT introduce ripple effects like the buttons. These widgets may be useful for use cases like – drawing, charts, drag and drop, etc.

When to use each:

  • Use Button widgets when you want a simple, pre-designed button with material design characteristics.
  • Use Ink widgets when you want to create a custom button with an ink splash effect.
  • Use Material widgets when you want to create a custom background with material design characteristics.
  • Use GestureDetector when you need more control over gesture detection, such as detecting specific gestures or handling multiple gestures simultaneously.

Here’s an example of how you might use each:

// GestureDetector (Gesture)
GestureDetector(
  onTap: () {},
  child: Container(
    width: 100,
    height: 50,
    color: Colors.blue,
  ),
)

In these examples, we’re using each widget to create a simple button or container that responds to taps. The ElevatedButton and Material widgets provide a material design background, while the InkWell widget creates an ink splash effect. The GestureDetector widget allows us to detect taps and other gestures on the container. It is up to you to actually make a higher level reusable components that actually have paremeters according to common states. One such library may be widget_toolkit,

Ultimately, the choice of which widget to use depends on your specific design requirements and the behavior you want to achieve.

  • What are ways to Optimize the backend endpoints in Spring Boot
  • Flutter image flickers
  • Could a Flutter App save a Flag even after uninstall
  • Could iOS flutter app logs be viewed while running in release mode – started after previous closed state
  • 6 Addictive Mobile Game Ideas Inspired by Flappy Bird’s Simplicity

Categories

  • Apps (20)
  • ChatGPT (19)
  • Choosing a Framework (38)
  • Flutter (206)
  • Graphical User Interface (13)
  • Marketing (114)
  • Software Development (270)
  • Spring (43)
  • StartUp (21)
  • Uncategorized (4)
  • Uncategorized (15)
  • Vaadin (14)

Tags

Algorithms (9) crypto (29) flutterdev (39) General (86) Java (7) QR & Bar Codes (3) Software Dev Choices (33) Spring Boot (1) standards (1) Theme (3) User Authentication & Authorization (9) User Experience (10) Utilities (19) WordPress (11)

Product categories

  • All Technologies (83)
    • Flutter Apps (23)
    • GPT (4)
    • Java (38)
    • Native Android (3)
    • PHP (9)
    • Spring (Boot) / Quarkus (35)
    • Utils (15)
    • Vaadin 24+ (27)
    • Vaadin 8 (1)
  • Apps (18)
    • Employees DB (1)
    • Notes (6)
    • Personal Budget (1)
    • Recipes Book (1)
    • Stuff Organizer (1)
    • To-Do (2)
  • PDF Books (3)
  • Source Code Generators (8)

Recent Posts

  • What are ways to Optimize the backend endpoints in Spring Boot
  • Flutter image flickers
  • Could a Flutter App save a Flag even after uninstall
  • Could iOS flutter app logs be viewed while running in release mode – started after previous closed state
  • 6 Addictive Mobile Game Ideas Inspired by Flappy Bird’s Simplicity

Post Categories

  • Apps (20)
  • ChatGPT (19)
  • Choosing a Framework (38)
  • Flutter (206)
  • Graphical User Interface (13)
  • Marketing (114)
  • Software Development (270)
  • Spring (43)
  • StartUp (21)
  • Uncategorized (4)
  • Uncategorized (15)
  • Vaadin (14)