If your requirement was simply empty or null (like mine when I saw this title in a search result), you can use Dart’s safe navigation operator to make it a bit more terse:
if (routeinfo["no_route"]?.isEmpty ?? true) {
//
}
Where
isEmptychecks for an empty String, but if routeinfo isnullyou can’t call isEmpty on null, so we check for null with?.safe navigation operator which will only call isEmpty when the object is not null and produce null otherwise. So we just need to check for null with??null coalescing operator
If your map is a nullable type then you have to safely navigate that:
if (routeinfo?["no_route"]?.isEmpty ?? true) {
//
}