safeGetInt static method
Safely extracts an int value from a map with fallback.
This method centralizes the safe int extraction pattern that was repeated throughout the codebase for index and count values.
map The map to extract from
key The key to extract
fallback The fallback value if extraction fails
Returns the extracted int value or fallback
Implementation
static int safeGetInt(
Map<dynamic, dynamic> map,
String key, {
int fallback = 0,
}) {
final value = map[key];
if (value is num) {
return value.toInt();
}
return fallback;
}