Home > front end >  Why im get this The argument type 'String?' can't be assigned to the parameter type &
Why im get this The argument type 'String?' can't be assigned to the parameter type &

Time:12-01

Why im getting (The argument type 'String?' can't be assigned to the parameter type 'String') error.

declaring variables

CodePudding user response:

Try below code:

Text(tab.text.toString())

or

Text('${tab.text}')

or

Text(tab.text!)

CodePudding user response:

Because Dart has null safety and it does not know whether your map has value in it or not. So using null check operator would solve your problem

return Center(child:Text(tab.text!));

CodePudding user response:

i have seen your code may be tab.text is returning nullable value and Text widget does not accept nullable value so please can you try to put Text(tab.text ?? "") in Text widget.

  • Related