flutter list dynamic to list int
List<dynamic> dynList = [1,2,3,4,5];
List<int> intList = dynList.cast<int>();
flutter list dynamic to list int
List<dynamic> dynList = [1,2,3,4,5];
List<int> intList = dynList.cast<int>();
create a int list dart
// a simple a.to(b) solution:
extension RangeExtension on int {
List<int> to(int maxInclusive) =>
[for (int i = this; i <= maxInclusive; i++) i];
}
// or with optional step:
extension RangeExtension on int {
List<int> to(int maxInclusive, {int step = 1}) =>
[for (int i = this; i <= maxInclusive; i += step) i];
}
// use the last one like this:
void main() {
// [5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50]
print(5.to(50, step: 3));
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us