title: How to access index number of a listView builder from outside the return function of itemBuilder?
body: <p>This is my list of items.</p>
  
  <pre><code>class MealsListData {
    String titleTxt;
    String startColor;
    String endColor;
    List&lt;String&gt; meals;
    int index;
  
    MealsListData({
      this.titleTxt = '',
      this.startColor = "#ffbf00",
      this.endColor = "#FFDF29",
      this.meals,
      this.index,
    });
  
    static List&lt;MealsListData&gt; tabIconsList = [
      MealsListData(
        titleTxt: 'Breakfast',
        meals: ["Bread", "Peanut butter", "Apple"],
        index: 1
      ),
      MealsListData(
        titleTxt: 'Lunch',
        meals: ["Salmon", "Mixed veggies", "Avocado"],
        index: 2
      ),
      MealsListData(
        titleTxt: 'Snack',
        meals: ["Recommend:", "800 kcal"],
        index: 3
      ),
    ];
  }
  </code></pre>
  
  <p>I'm displaying a list of cards on the screen using ListView.
  Each of the MealsListData values in the above code corresponds to one card.
  What I want is when the user touches a card, that specific card should open up separately in a new window. 
  The following is my ListView. I have wrapped mealsView widget indside an InkWell widget and used that as the return value of itemBuilder.
  The original code did not have InkWell widget present.</p>
  
  <pre><code>ListView.builder(
                      padding: const EdgeInsets.only(
                          top: 0, bottom: 0, right: 16, left: 16),
                      itemCount: mealsListData.length,
                      scrollDirection: Axis.horizontal,
                      itemBuilder: (context, index) {
                        var count =
                            mealsListData.length &gt; 10 ? 10 : mealsListData.length;
                        var animation = Tween(begin: 0.0, end: 1.0).animate(
                            CurvedAnimation(
                                parent: animationController,
                                curve: Interval((1 / count) * index, 1.0,
                                    curve: Curves.fastOutSlowIn)));
                        animationController.forward();
  
                        return InkWell( 
                                  onTap: () {MyDiaryScreen2(
                                          itemIndex: MealsListData().index);
                                          print(MealsListData().index);},
                                  child: MealsView(
                                      mealsListData: mealsListData[index],
                                      animation: animation,
                                      animationController: animationController,
                                      itemIndex: index,
                                    ));
                      }
                    ), 
  </code></pre>
  
  <p>The following is the code of MealsView the class I'm using to get one card. </p>
  
  <pre><code>class MealsView extends StatelessWidget {
    final MealsListData mealsListData;
    final AnimationController animationController;
    final Animation animation;
    final int itemIndex;
  
    const MealsView(
        {Key key, this.mealsListData, this.animationController, this.animation, this.itemIndex})
        : super(key: key);
  
  @override
    Widget build(BuildContext context) {
      return AnimatedBuilder(
        animation: animationController,
        builder: (BuildContext context, Widget child) {
          return FadeTransition(
            opacity: animation,
            child: new Transform(
              transform: new Matrix4.translationValues(
                  100 * (1.0 - animation.value), 0.0, 0.0),
                  //this is the individual card
              child: SizedBox(
                width: 200,
                child: 
                    Padding(
                      padding: const EdgeInsets.only(
                          top: 32, left: 8, right: 8, bottom: 16),
                      child: Container(
                                     child: Padding(
                                          padding: const EdgeInsets.only(
                                             top: 22, left: 16, right: 16, bottom: 8),
                                          child: Column(
                                            mainAxisAlignment: MainAxisAlignment.center,
                                            crossAxisAlignment: CrossAxisAlignment.start,
                                            children: &lt;Widget&gt;[
                                            Text(
                                              mealsListData.titleTxt,
                                              textAlign: TextAlign.center,
                                            ),
                                         //Heading(Inside card) Style closed
                                            Expanded(
                                             child: Padding(
                                              padding:
                                               const EdgeInsets.only(top: 22, bottom: 8),
                                              child: Row(
                                                mainAxisAlignment: MainAxisAlignment.start,
                                                crossAxisAlignment: CrossAxisAlignment.start,
                                                children: &lt;Widget&gt;[
                                                 //this is the list of items
                                                 Text(
                                                   mealsListData.meals.join("\n"),
                                                 ),
                                    ],
                                  ),
                                ),
                              ),                            
                            ],
                          ),
                        ),
  
                    ),                                
  
              ),
            )
          )
          );
        },
      );
    }
  </code></pre>
  
  <p>What am I doing wrong? When I tap on the cards the index number should be printed on debug console but all I get is NULL.</p>