10 lines
382 B
Dart
10 lines
382 B
Dart
/// Parse a value that may be [int], [num], or [String] to [int].
|
|
/// Used as `@JsonKey(fromJson: flexibleInt)` and in manual `fromJson` factories
|
|
/// to handle Plex API responses where numeric fields may arrive as strings
|
|
/// (XML-to-JSON conversion).
|
|
int? flexibleInt(Object? v) => switch (v) {
|
|
num n => n.toInt(),
|
|
String s => int.tryParse(s),
|
|
_ => null,
|
|
};
|