Flutter : how to make an entire row clickable

flutter clickable image
flutter clickable widget
flutter inkwell
gesturedetector flutter
flutter click on screen
flutter clickable text
click on container in flutter
flutter row spacing

How do I make the entire row clickable in flutter?. I have the following code wrap in a "GestureDetector". The individual items in the row are clickable but white space around the widget are not.

if ((auth.isLoggedIn)) ...[
   GestureDetector(
     onTap: () {
        auth.signOut();
     },
     child: buildItem(
        Image.asset("assets/images/logoff.png",),
        "logout"
     ),
   ),
],

This is the "buildItem" method

Widget buildItem(Widget icon, String title) {
    return Padding(
      padding: const EdgeInsets.only(left: 20, right: 15),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: <Widget>[
          Container(
              child: Row(
            children: <Widget>[
              icon,
              SizedBox(width: 20.0),
              Text(
                title,
                style: TextStyle(
                  fontSize: 16.0,
                ),
              ),
            ],
          )),
          Icon(
            Icons.arrow_forward_ios,
            size: 20.0,
          ),
        ],
      ),
    );
  }

This is the output. Each item in the row (icon, text and the >) respond to the tap gesture. However, the white space(e.g between the text and the ">") does not respond to tap

How can I make entire row respond to the tap.


replace GestureDetector with InkWell works great

full code

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            InkWell(
              onTap: () {
                print("click");
              },
              child: buildItem(
                  Image.network("https://picsum.photos/250?image=9",),
                  "logout"
              ),
            ),
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.display1,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}

Widget buildItem(Widget icon, String title) {
  return Padding(
      padding: const EdgeInsets.only(left: 20, right: 15),
      child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            Container(
                child: Row(
                  children: <Widget>[
                    icon,
                    SizedBox(width: 20.0),
                    Text(
                      title,
                      style: TextStyle(
                        fontSize: 16.0,
                      ),
                    ),
                  ],
                )),
            Icon(
              Icons.arrow_forward_ios,
              size: 20.0,
            ),
          ],
      ),
  );
}

Flutter: How do you make a card clickable?, of the user, creates the rebound effect with the chosen color, on the card .. Sometimes, we may need to create custom widgets which are clickable. Let’s see how to make container widget clickable widget in Flutter. The GestureDetector widget is used to detect gestures. Hence, we use GestureDetector in this example so that we can detect taps on the container.


  child: GestureDetector(
      behavior: HitTestBehavior.translucent,
      onTap: () {
      ///
      },

How to create a hyperlink in Flutter widget?, widget must have a Material widget as an ancestor. The Material widget is where the ink reactions are actually painted. HTML has two basic types of elements, inline elements and block elements. If you want to know more about it, just read here.. Because them <a> tag belongs to the class of the inline elements, it won't fill the whole table cell.


row: mainAxisAlignment: MainAxisAlignment.spaceBetween

For space between, the first and the last object will stick to the edge of the container, while leaving the empty unused space in between (if there is other objects, it will distributed it evenly), like shown in the screenshot below:

Hence to solve this, you just have to make sure that there is no empty space between.

One way is to use mainAxisSize: MainAxisSize.max and MainAxisAlignment.start in the Row where you put your icon and text.

Flutter Button onPressed() Tutorial, Have you tried using InkWell()?. Favorite heart outline button Favorite heart button 2. REPLY. I'm still having a bit of trouble with the layouting in Flutter. Right now I want to have the available space shared between 3 widgets, in a quadrant layout. The width is evenly shared (this works fine via 2 Expanded widgets in a Row), but now I also want the height to adjust automatically so widget3.height == widget1.height + widget2.height.


InkWell class - material library - Dart API, Sometimes, we may need to create custom widgets which are clickable. Let's see how to make container widget clickable widget in Flutter. How to Arrange Children Widgets in Row and Column in FlutterJanuary 23, 2020In "Flutter Tutorials"  Create a Todos app with Flutter and Provider Shakib Hossain - Jun 3 '19. iPod Touch 7th Gen - Made for Devs? Sethu Senthil - Jun 2 '19. Rui Kowase.


How to add a click event to any widget of Flutter, replace GestureDetector with InkWell works great. full code import 'package:​flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends  1. You should use the onPressed method in the item (s) you have in your ListView (or add a GestureDetector) then use Navigator, similar to the snippet below where AboutScreen is the next page you want to go to. onPressed: () { Navigator.push( context, MaterialPageRoute(builder: (context) => AboutScreen()), ); } share.


How to Make Container Clickable in Flutter – Flutter For You, Data tables display sets of data across rows and columns. Flutter, Available They organize information in a way that's easy to scan, so that users can look for patterns A selected row checkbox with background fill color on the entire row  A Row is a widget used to display child widgets in a horizontal manner. The Row widget does not scroll. If you have a line of widgets and want them to be able to scroll if there is insufficient