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<T> newList(int length, {bool growable = false, bool reactive = true}) {
// Construct a new list.
final defaultInstance = newInstance();
final list = List<T>.filled(
length,
defaultInstance,
growable: growable,
);
// Wrap with ReactiveList?
if (reactive) {
return ReactiveList<T>.wrap(list);
}
return list;
}