Berke Kılıç
Berke Kılıç

Reputation: 15

Flutter text data if coming null?

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.

Upvotes: 0

Views: 86

Answers (3)

My Car
My Car

Reputation: 4566

Try this:

Text(
  '${sucessful ?? "No email"} \n \n'  
  style: TextStyle(
    fontSize: 22.0,
    fontStyle: FontStyle.normal,
    fontWeight: FontWeight.w300,
    color: Colors.black,
    letterSpacing: 0,
  ),
),

Upvotes: 1

Usama majid
Usama majid

Reputation: 202

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

Upvotes: 0

Amitha Mohanan
Amitha Mohanan

Reputation: 21

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

Upvotes: 2

Related Questions