Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example showing how to update a list
class Person {
Person(this.name);
final String name;
String toString() => name;
}
void main() {
final items = [Person("juan"), Person("pedro"), Person("coso")];
print("before update:");
print(items);
final index = items.indexWhere((p) => p.name == 'pedro');
if (index != -1) {
items[index] = Person("otro");
}
print("after update:");
print(items);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment