Home > Software design >  Flutter text data if coming null?
Flutter text data if coming null?

Time:03-28

There is such a code and if the user is logged in as a visitor, it prints null because there is no e-mail information, how can I show it blank?

 Text(
    '$successmail \n\n'  
    style: TextStyle(
    fontSize: 22.0,
    fontStyle: FontStyle.normal,
    fontWeight: FontWeight.w300,
    color: Colors.black,
    letterSpacing: 0,
    ),
    ),

I tried putting things like question marks at the end of the variable but I don't know how to do it exactly.

CodePudding user response:

successmail == null ? SizedBox.shrink : Text(
    '$successmail \n\n'  
    style: TextStyle(
    fontSize: 22.0,
    fontStyle: FontStyle.normal,
    fontWeight: FontWeight.w300,
    color: Colors.black,
    letterSpacing: 0,
    ),
    ),

try this way

CodePudding user response:

On text widget try this: "${sucessful ?? "No email"} \n \n"

  • Related