findStateByName method
Finds a state by its name.
name: The name to search for.- Returns: The state object with the matching name.
- Throws: An exception if no state with the given name is found.
Implementation
T findStateByName(String name) {
for (var state in states) {
if (getName(state).equalsIgnoreCase(name)) {
return state;
}
}
throw Exception("Invalid name provided!");
}