I want to retrieve value from if statement of data not a null. At some point the data will be null so with my code it will return the initialize of string. How I want to retrieve the value from if condition that be null
String stringCheck() {
var checkStatus;
if (truckState.reported != null) {
var devStatus = truckState.reported?.data?.status;
checkStatus = devStatus;
return checkStatus;
}
return checkStatus;
}
I tried this somehow checkStatus still return null but I need data that hold inside if condition