I was upgraded my flutter project version to the latest (2.5.3). then occurred some errors due to unsupported null-safety
. I had fixed many but still, haven't any idea to fix following null-safety
to error,
Code
itemBuilder: (context, suggestion) {
return ListTile(
subtitle: Text(
suggestion.stateA == null || suggestion.stateB == null
? '${suggestion.city}, ${suggestion.country}'
: '${suggestion.city}, ${suggestion.state}, ${suggestion.country}',
style: Theme.of(context).textTheme.bodyText,
),
);
}
Errors
The property 'stateA' can't be unconditionally accessed because the receiver can be 'null'.
The property 'stateB' can't be unconditionally accessed because the receiver can be 'null'.
The property 'city' can't be unconditionally accessed because the receiver can be 'null'.
The property 'country' can't be unconditionally accessed because the receiver can be 'null'.
how add the check null-safety above code?
I already try with !
& ?
Operator but it does not work for me
(i.e. suggestion!.state
)