Home > other >  Flutter: _TypeError (type 'Null' is not a subtype of type 'String')
Flutter: _TypeError (type 'Null' is not a subtype of type 'String')

Time:02-02

Can someone help with this error? print() retrieve me the data from firebase but when I try to access them in the widegt the erros apears

error image

CodePudding user response:

What really happened is, you're trying to use a value, which is null, but, the Text widget is expecting a string, rather than null. This is the root cause of your error.

You can fix the error by making sure your data is not null or you can use a null safe operator on your nullable data.

Example:

Text(userData['name'] ?? 'name not found')

Happy coding :D

  •  Tags:  
  • Related