int? stringToInt(String value, [int? defaultValue]) { if (value is! String) { return defaultValue; } return int.tryParse(value) ?? defaultValue; }