The argument type 'String?' can't be assigned to the parameter type 'String'. in carousel image flutter model -

Viewed 25

I'm gettin stuck in put my image carousel from model carousel_model.dart enter image description here

enter image description here//i.stack.imgur.com/Qp92R.png

1 Answers

Your CarouselModel's image variable data type is String. But reading a map can provide null data for unknown keys(the keys arent include on map).

You can provide default value on null case or do a null check then add into list.

Providing default empty string on null case.

=> CarouselModel(item['image']??"")).toList()

If item is nullable do item?['image']??""

Related