samedi 2 janvier 2021

Adding icon dynamically if a condition is true

I'm trying to add an icon inside my app only if a condition is True, also I want it to be added dynamically, Here's a pseudo-code which I am trying to work in:

subtitle: Row(
    children: <Widget>[
      Container(
        child: HebrewText(helpRequest.description),
        //alignment: Alignment.centerLeft,
        padding: const EdgeInsets.only(top: 8, left: 8),
      ),
      Spacer(),
      GestureDetector(
        onTap: ()=>{
          if(helpRequest.handler_id != null) {
                  _launchCaller(),
          },
        } ,
          child: Padding(
              padding: EdgeInsets.all(16.0),
              child: Icon(
                Icons.call,
                size: 20.0,
                color: BasicColor.clr,
              )),
        ),

    ],
  ),

I want the gestureDetector to be add to this row only if a condition is true, Tries to add if condition before the GestureDetector() but it didn't work, is there any simple way to make it?

As you see in my code I put the if condition inside the OnTap, I want to make it on the GestureDetector

Aucun commentaire:

Enregistrer un commentaire