Skip to content

Commit

Permalink
Fixed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vanlooverenkoen committed Apr 20, 2021
1 parent 5895752 commit 2171c33
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/src/extension/list_extensions.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:icapps_architecture/src/extension/iterable_extensions.dart';

extension ListExtensions<T> on List<T> {
///Replaces all data in the list with [newData]
void replaceAll(List<T> newData) {
Expand All @@ -9,14 +7,13 @@ extension ListExtensions<T> on List<T> {

///Replaces all items that matches where with [newData]
void replaceWhere(bool Function(T) where, T newData, {int? count}) {
final whereResult = this.where(where);
whereResult.forEachIndexed((index, result) {
if (count != null && index >= count) return;
if (result == null) return;
final originalIndex = indexOf(result);
removeAt(originalIndex);
insert(originalIndex, newData);
});
final replaceCount = count ?? length;
final whereResult = this.where(where).toList();
for (var i = 0; i < whereResult.length; ++i) {
if (i >= replaceCount) break;
final result = whereResult[i];
this[indexOf(result)] = newData;
}
}

/// Sorts the list based on the comparable returned by [by]. By default
Expand Down

0 comments on commit 2171c33

Please sign in to comment.