dart:collection 庫中ListMixin.fillRange 方法的用法介紹如下。
用法:
void fillRange(
int start,
int end,
[E? fill]
)
override
用 fillValue 覆蓋一係列元素。
將大於或等於 start 且小於 end 的位置設置為 fillValue 。
start 和 end 提供的範圍必須有效。如果 0 ≤ start ≤ end ≤ length ,則從 start 到 end 的範圍是有效的。空範圍(帶有 end == start )是有效的。
如果元素類型不可為空,則必須提供 fillValue 並且必須是非 null 。
例子:
final words = List.filled(5, 'old');
print(words); // [old, old, old, old, old]
words.fillRange(1, 3, 'new');
print(words); // [old, new, new, old, old]
相關用法
- Dart ListMixin.first用法及代碼示例
- Dart ListMixin.firstWhere用法及代碼示例
- Dart ListMixin.followedBy用法及代碼示例
- Dart ListMixin.forEach用法及代碼示例
- Dart ListMixin.fold用法及代碼示例
- Dart ListMixin.expand用法及代碼示例
- Dart ListMixin.contains用法及代碼示例
- Dart ListMixin.join用法及代碼示例
- Dart ListMixin.setAll用法及代碼示例
- Dart ListMixin.where用法及代碼示例
- Dart ListMixin.toList用法及代碼示例
- Dart ListMixin.lastIndexOf用法及代碼示例
- Dart ListMixin.toSet用法及代碼示例
- Dart ListMixin.reversed用法及代碼示例
- Dart ListMixin.take用法及代碼示例
- Dart ListMixin.insertAll用法及代碼示例
- Dart ListMixin.reduce用法及代碼示例
- Dart ListMixin.removeWhere用法及代碼示例
- Dart ListMixin.getRange用法及代碼示例
- Dart ListMixin.sort用法及代碼示例
- Dart ListMixin.removeLast用法及代碼示例
- Dart ListMixin.replaceRange用法及代碼示例
- Dart ListMixin.takeWhile用法及代碼示例
- Dart ListMixin.sublist用法及代碼示例
- Dart ListMixin.lastWhere用法及代碼示例
注:本文由純淨天空篩選整理自dart.dev大神的英文原創作品 fillRange method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
