what I need is to wrap "return InkWell" in a card – flutter

Issue

How do I wrap InkWell in a Card, I need InkWell to be wrapped in a card:

card : Card(
                            elevation: 4.0,
                            child: Stack(
                              fit: StackFit.loose,

    //add Card
    return InkWell(
          onTap: () => Navigator.push(
            context,
            MaterialPageRoute(
          builder: (BuildContext context) => ImageScreen(
            url: '${_productosModel[index].image}' + '?alt=media',
          ),
        ),
          ),
          child: Expanded(
            child: CachedNetworkImage(
              imageUrl: '${_productosModel[index].image}' + '?alt=media',
              fit: BoxFit.cover,
              placeholder: (_, __) {
                return Center(
                  child: CupertinoActivityIndicator(
                    radius: 15,
                  ),
                );

              },
            ),
          ),
        ),

Solution

I think you just need to wrap Inkwell in Card

return Card(
   child: InkWell(
      onTap: () => Navigator.push(
        context,
        MaterialPageRoute(
      builder: (BuildContext context) => ImageScreen(
        url: '${_productosModel[index].image}' + '?alt=media',
      ),
    ),
      ),
      child: Expanded(
        child: CachedNetworkImage(
          imageUrl: '${_productosModel[index].image}' + '?alt=media',
          fit: BoxFit.cover,
          placeholder: (_, __) {
            return Center(
              child: CupertinoActivityIndicator(
                radius: 15,
              ),
            );

          },
        ),
      ),
    )
)

Answered By – Ananda Pramono

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published