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'
    – KuKu
    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

1
  • 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.
    – Community Bot
    Mar 28, 2022 at 7:31
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,
  ),
),
0

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

2
  • 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"}") Apr 3, 2022 at 13:11
  • you can use companies.file1 != null ? NetworkImage("yourLink") : NetworkImage("YourOtherLink") Apr 4, 2022 at 0:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.