mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
13 lines
267 B
Dart
13 lines
267 B
Dart
extension EnumListX<T> on List<T> {
|
|
T fromIndex(int index, [T? defaultValue]) {
|
|
try {
|
|
return this[index];
|
|
} catch (e) {
|
|
if (defaultValue != null) {
|
|
return defaultValue;
|
|
}
|
|
throw Exception('Invalid index: $index');
|
|
}
|
|
}
|
|
}
|