showModalBottomSheet how can i navigate with data

Issue

enter image description hereenter image description here

When the item in the listview is clicked, I want to move the information to the bottom sheet, but I couldn’t find the way.
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => customBottomSheet(context),
),i tried but it didn’t work how can i solve this problem

return Expanded(
                      child: ListView.builder(
                          shrinkWrap: true,
                          scrollDirection: Axis.vertical,
                          itemCount: coinListForDisplay.length,
                          itemBuilder: (context, index) {
                            return InkWell(
                              onTap: (() {
                                customBottomSheet(context);
                              }),
                              child: ListViewCard(
                                name: coinListForDisplay[index].name,
                                symbol: coinListForDisplay[index].symbol,
                                imageUrl: coinListForDisplay[index].imageUrl,
                                price:
                                    coinListForDisplay[index].price.toDouble(),
                                change:
                                    coinListForDisplay[index].change.toDouble(),
                                changePercentage: coinListForDisplay[index]
                                    .changePercentage
                                    .toDouble(),
                              ),
                            );
                          }),
                    );```

Solution

You can pass data in parameters like this.
In you custom bottom sheet, use

CustomBottomSheet(BuildContext context,yourData){
    //Your code
}

And in your onTap function use

CustomBottomSheet(context,yourData);

Answered By – Sheikh Haziq

Answer Checked By – Mildred Charles (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *