0

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.

1
  • '$successmail \n\n' -> successmail == null || successmail.isEmpty ? '' : '$successmail \n\n' Commented Mar 28, 2022 at 6:25

3 Answers 3

2
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

Sign up to request clarification or add additional context in comments.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
1

Try this:

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

Comments

0

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

2 Comments

Hi, how can i use on this example ? i try this way but its doesnt work. image: NetworkImage( "https://example.com/${companies.file1 ?? "0.png"}")
you can use companies.file1 != null ? NetworkImage("yourLink") : NetworkImage("YourOtherLink")

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.