isListOfListValuesAllEquals function

bool isListOfListValuesAllEquals(
  1. Iterable<List>? list, {
  2. Object? eqValue,
  3. int? eqValueIndex,
})

Returns true if list elements are all equals to value at index valueIndex.

Implementation

bool isListOfListValuesAllEquals(Iterable<List>? list,
    {Object? eqValue, int? eqValueIndex}) {
  if (list == null) return false;

  if (list.isEmpty) return false;

  eqValue ??= eqValueIndex != null
      ? list.first[eqValueIndex]
      : list.firstWhere((e) => e.isNotEmpty).first;

  if (eqValueIndex != null) {
    return listMatchesAll(list, (v) => v[eqValueIndex] == eqValue);
  } else {
    return listMatchesAll(list, (v) => v == eqValue);
  }
}