Created
April 6, 2022 07:40
-
-
Save mhmadip/72e9360eb080c523fa1bfc327789c9f5 to your computer and use it in GitHub Desktop.
Creating Objects using Loop and store them in a list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object { | |
int id = 0; | |
String name='abc'; | |
Object(this.id); | |
@override | |
String toString()=> id.toString() + name; | |
} | |
void main() { | |
var list =<Object> []; | |
for (var x = 1; x < 10; x++) { | |
list.add(Object(x)) ; | |
} | |
print(list); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment