validateHomogeneousType function
Validates that all elements in the list are of the same runtimeType.
Implementation
void validateHomogeneousType(List<dynamic> list, {String message = 'Inconsistent data types in list.'}) {
if (list.isEmpty) return;
final type = list.first.runtimeType;
if (list.any((e) => e.runtimeType != type)) {
throw ArgumentError(message);
}
}