dart:html
庫中PluginArray.length
屬性的用法介紹如下。
用法一
int length
override
此列表中的對象數。
列表的有效索引是 0
到 length - 1
。
final numbers = <int>[1, 2, 3];
print(numbers.length); // 3
用法二
void length=(int value)
override
設置 length
會更改列表中的元素數量。
列表必須是可增長的。如果 newLength
大於當前長度,則新條目將初始化為 null
,因此如果元素類型 E
不可為空,則 newLength
不得大於當前長度。
final maybeNumbers = <int?>[1, null, 3];
maybeNumbers.length = 5;
print(maybeNumbers); // [1, null, 3, null, null]
maybeNumbers.length = 2;
print(maybeNumbers); // [1, null]
final numbers = <int>[1, 2, 3];
numbers.length = 1;
print(numbers); // [1]
numbers.length = 5; // Throws, cannot add `null`s.
相關用法
- Dart PluginArray.last用法及代碼示例
- Dart PluginArray.elementAt用法及代碼示例
- Dart PluginArray.first用法及代碼示例
- Dart Platform.localeName用法及代碼示例
- Dart Platform用法及代碼示例
- Dart Point用法及代碼示例
- Dart Process用法及代碼示例
- Dart Point.magnitude用法及代碼示例
- Dart Point.operator_minus用法及代碼示例
- Dart Point.distanceTo用法及代碼示例
- Dart Point.operator_equals用法及代碼示例
- Dart Point.squaredDistanceTo用法及代碼示例
- Dart Pattern.matchAsPrefix用法及代碼示例
- Dart Process.start用法及代碼示例
- Dart Pattern.allMatches用法及代碼示例
- Dart Point.operator_plus用法及代碼示例
- Dart Process.run用法及代碼示例
- Dart Point.operator_multiply用法及代碼示例
- Dart MapMixin.containsKey用法及代碼示例
- Dart Iterator用法及代碼示例
- Dart AttributeClassSet.intersection用法及代碼示例
- Dart num.sign用法及代碼示例
- Dart TransformList.last用法及代碼示例
- Dart FileList.first用法及代碼示例
- Dart CanvasRenderingContext2D.drawImageScaledFromSource用法及代碼示例
注:本文由純淨天空篩選整理自dart.dev大神的英文原創作品 length property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。