1

The argument type 'String?' can't be assigned to the parameter type 'String'

how can pass the parameter ?

enter image description here

enter image description here

MSameer
  • 35
  • 5

2 Answers2

6

You can try this

child: TipsCard(
//
image:tipsPages[i]["image"] as String,//
)
Rasathurai Karan
  • 673
  • 5
  • 16
2

You can do this:

//...

child: TipsCard(
//...
image: tipsPages[i]["image"] ?? "", // Replace this blank "" with a default image url of your choice
),
Bach
  • 2,928
  • 1
  • 6
  • 16
  • it's work thank you but I want to ask you why it's want after initialize char "?" like (String?) and how can remove this feature ? @Bach – MSameer Aug 09 '21 at 18:40
  • @MSameer This is a feature introduce with Dart 2.0, kind of like a revolution change that make Dart a null-safe language, so the only way to not using it is to convert Dart back to 1.0. The `?` is to indicate that the variable can be null. My recommendation is to learn using this feature instead of turning it off, since it'll help us a lot in avoiding potential bugs with null values. There's a quite nice video here from Flutter team: https://www.youtube.com/watch?v=iYhOU9AuaFs – Bach Aug 10 '21 at 09:11