title: How do I get the selected index in a Row in flutter
body: <p><a href="https://i.stack.imgur.com/UgBb9.png" rel="nofollow noreferrer">Date selector</a></p>
  
  <p>I want to build a date selector for user to select the date they want to book a class.
  So far I have coded the logic to generate next 8days and display it in a row, but I have trouble getting the selected index when user tap a date.
  How do I achieve that?</p>
  
  <p>Thank you very much.</p>
  
  <pre><code>class TimeSlot extends StatelessWidget {
    List&lt;Map&lt;String, String&gt;&gt; get upComingDay {
      return List.generate(8, (index) {
        final weekDay = DateTime.now().add(
          Duration(days: index),
        );
        return {
          'day': DateFormat.E().format(weekDay).substring(0, 2),
          'date': DateFormat.d().format(weekDay),
        };
      });
    }
  
    @override
    Widget build(BuildContext context) {
      return Row(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        children: upComingDay.map((data) {
          return Column(
            children: &lt;Widget&gt;[
              Text(
                data['day'],
                style: TextStyle(
                  color: Color.fromRGBO(30, 41, 51, 0.5),
                ),
              ),
              SizedBox(
                height: 7,
              ),
              GestureDetector(
                onTap: () {},
                child: CircleAvatar(
                  backgroundColor: Color.fromRGBO(240, 242, 245, 1),
                  radius: 14,
                  child: CircleAvatar(
                    backgroundColor: Colors.white,
                    child: Text(
                      data['date'],
                      style: TextStyle(color: Colors.black, fontSize: 12),
                    ),
                    radius: 13,
                  ),
                ),
              ),
            ],
          );
        }).toList(),
      );
    }
  }
  </code></pre>