Home > OS >  what I need is to wrap "return InkWell" in a card - flutter
what I need is to wrap "return InkWell" in a card - flutter

Time:10-21

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,
                  ),
                );

              },
            ),
          ),
        ),

CodePudding user response:

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,
              ),
            );

          },
        ),
      ),
    )
)
  • Related