simc / dartx

Superpowers for Dart. Collection of useful static extension methods.
https://pub.dev/packages/dartx
Apache License 2.0
1.08k stars 88 forks source link

`takeFirst` and `takeLast` are not index safe #155

Closed philippschweig closed 2 years ago

philippschweig commented 2 years ago

takeFirst and takeLast are not index safe.

Excerpt of takeFirst: sublist is not index safe

extension IterableTakeFirst<E> on Iterable<E> {
  List<E> takeFirst(int n) {
    final list = this is List<E> ? this as List<E> : toList();
    return list.sublist(0, n);
  }
}
passsy commented 2 years ago

Already fixed #156