Метод remove
- Object? element
override
Удаляет первое вхождение value из этого списка.
Возвращает true, если value был в списке, в противном случае — false. Список должен быть изменяемым.
final parts = <String>['head', 'shoulders', 'knees', 'toes'];
final retVal = parts.remove('head'); // true
print(parts); // [shoulders, knees, toes] Метод не оказывает никакого влияния, если value не был в списке.
final parts = <String>['shoulders', 'knees', 'toes'];
// Note: 'head' has already been removed.
final retVal = parts.remove('head'); // false
print(parts); // [shoulders, knees, toes] Реализация
bool remove(Object? element) {
for (int i = 0; i < this.length; i++) {
if (this[i] == element) {
this._closeGap(i, i + 1);
return true;
}
}
return false;
}
© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.18.5/dart-collection/ListMixin/remove.html