Search
 
SCRIPT & CODE EXAMPLE
 

DART

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));
}
Comment

PREVIOUS NEXT
Code Example
Dart :: flutter copy 
Dart :: dart loop 
Dart :: dart list equality 
Dart :: flutter otp input scrren 
Dart :: alternate of string class in dart 
Dart :: Flutter: How do you make a card clickable? 
Dart :: string to int in dart, string to double in dart, int to string in dart 
Dart :: odd even in dart 
Dart :: Array of colors in dart 
Dart :: function in dart 
Dart :: flutter Explain Hot Reload in 
Dart :: flutter logo flutter 
Dart :: @override in dart 
Dart :: dart list of objects to json 
Dart :: late in dart 
Dart :: tooltip flutter 
Dart :: naming convention class names flutter 
Dart :: single clone data in flutter 
Dart :: dart test matcher expecting a field value 
Dart :: get value from map with key flutter 
Dart :: a function body must be provided. try adding a function body. flutter 
Dart :: how to parse json with missing key in lfutter 
Dart :: flutter container rounded corners 
Swift :: Detect if device is ipad or iphone swift 
Swift :: swift func for constraint 
Swift :: swift ui function with return value 
Swift :: swift get top constraint 
Swift :: swiftui vstack alignment 
Swift :: swiftui foreach 
Swift :: swift replace all characters except numbers 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =