The fillRange()
method overwrites a range of elements in the list with fillValue
.
start
: Represents the start index.end
: Represents the end index.fillValue
: Represents the value to be filled within the specified range in the list.The illustration below shows the visual representation of the list.fillRange()
method.
void main(){// Creating listvar numbers = [14, 21, 58, 30, 76, 93, 28];// Display resultprint("Original list: $numbers");// Overwriting items in the list// using fillRange()numbers.fillRange(1, 3, -10);print('New list: ${numbers}');}