I want to create a new address model. Doing so, beforehand I check a data structure if this contains specific information and then extract them and store it into a variable. After all if-clauses I want to use these variables to create a new object of type Address. However, all the in-between stored variables are not recognized:
final List type = c['types'];
if (type.contains('street_number')) {
final streetNumber = c['long_name'];
}
if (type.contains('route')) {
final street = c['long_name'];
}
if (type.contains('locality')) {
final city = c['long_name'];
}
if (type.contains('postal_code')) {
final zipCode = c['long_name'];
}
final address = Address(
country: null,
postalCode: zipCode, //Undefinex name 'zipCode'
city: city,
streetNumber: streetNumber,
long: null,
lat: null);
});