Home > Mobile >  How to add if child section
How to add if child section

Time:12-24

return InkWell(
          onTap: () => { if(1==0){
            Navigator.push(
              context,
              MaterialPageRoute(
                builder: (BuildContext context) =>
                    ImageScreen(
                      url: widget.userbio.resimler![index].toString(),
                    ),
              ),),
          }},

          child: Image.network(
            widget.userbio.resimler![index].toString(),
            fit: BoxFit.cover,


          )

      );

hello all stackoverflow users, ı need help for this. how can i add if here child: Image.network(widget.userbio.resimler![index].toString(),fit: BoxFit.cover,

If you have any other suggestions for me to solve such problems, please do.

CodePudding user response:

You can try this:

child: widget.userbio.resimler![index].toString().contains("keyword") ? Image.network(
    widget.userbio.resimler![index].toString(),
    fit: BoxFit.cover,
  ) : SizedBox()

here if condition be true, Image would be build, if be false, SizedBox would be build.

CodePudding user response:

You can do something like below

child : conditionTrue ? ImageFromNetowrk : null,

OR

child : conditionTrue ? ImageFromNetowrk : SizedBox(),
  • Related