newListGenerate method
A method similar to the list constructor List.generate.
The method allocates the most performant list possible. For instance,
Float32Kind,
will give you a dart:typed_data Float32List
rather than normal List<double>
(if growable
and reactive
are false).
Example
import 'package:kind/kind.dart';
void main() {
final kind = StringKind();
final list = kind.newListFromGenerator(
100,
(i)=>'initial value',
growable: false,
reactive: false,
);
}
Implementation
List<T> newListGenerate(
int length,
T Function(int i) function, {
bool growable = false,
bool reactive = true,
}) {
final list = List<T>.generate(
length,
function,
growable: growable,
);
if (reactive && (length != 0 || growable)) {
return ReactiveList<T>.wrap(list);
}
return list;
}