Introduction
Sometimes, we may wish to update a list item in Flutter/Dart. In this article, we'll look at how to do it.
Posts related to lists in Flutter/Dart:
- Filter items in a List in Flutter/Dart
- Sort a List in Flutter/Dart
- FlatMap a list of lists in Flutter/Dart
- Reverse a List in Flutter/Dart
- Iterate over List in Flutter/Dart
- Find elements in List in Flutter/Dart
- Remove items from a List in Flutter/Dart
- Access items from List in Flutter/Dart
- Create a list in Flutter/Dart
- Combine Lists in Flutter/Dart
How to update a list item in Flutter
There are several ways to update a list item/items in Flutter/Dart.
Replace item in a list using the []
operator
The output:
Replace items in a list using replaceRange()
method
Replace items from index 2 to 3:
The output:
Conclusion
In this post, we showcased two methods to replace/update an item in a list in Flutter/Dart.
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}