newList method
Returns a new list of this kind, which is guaranteed some properties.
The method allocates the most performant list possible. For instance,
Float32Kind,
will give you a dart:typed_data Float32List
rather than normal List<double>
.
Example
import 'package:kind/kind.dart';
void main() {
final kind = StringKind();
final list = kind.newList(
3,
growable: false,
reactive: false,
);
}
Implementation
@override
List<int> newList(int length, {bool growable = false, bool reactive = true}) {
if (growable) {
return super.newList(
length,
growable: growable,
reactive: reactive,
);
}
final list = Int8List(length);
if (reactive && length != 0) {
return ReactiveList<int>.wrap(list);
}
return list;
}