The parameter 'abc' can't have a value of 'null' because of its type, but the implicit default value is 'null'

147 Views Asked by At

@required to a property gave such ERROR: The parameter 'lng' can't have a value of 'null' because of its type, but the implicit default value is 'null'. (Documentation)

but removing @, removes the error. how ? I mean, the value still can be null. What does it have to do with "@" symbol.

see pictures: enter image description here

1

There are 1 best solutions below

0
Md. Yeasin Sheikh On

You dont need to use @ anymore, just use required.

({ 
  required this.lat,
  required this.lng,
})

if you like to accept null data, use DataType? varName.

String? lat;
String? lng;

More about understanding-null-safety