i method
获取 value 转 int
Implementation
int i(String key, {int defaultValue = 0, bool showLog = true}) {
if (!containsKey(key)) {
_log('当前map不存在 key:[$key]', showLog);
return defaultValue;
}
final value = this[key];
if (value is int) return value;
if (value is double) return value.toInt();
if (value == null) {
_log('[$key]的值为 null', showLog);
return defaultValue;
}
final other = int.tryParse(value.toString()) ?? defaultValue;
_log('${value.runtimeType} [$key]=$value => int:$other', showLog);
return other;
}