Skip to content

Instantly share code, notes, and snippets.

@Henrydykee
Created October 25, 2023 14:49
Show Gist options
  • Save Henrydykee/51f692d9be637763bf1af0bcd0c68f5f to your computer and use it in GitHub Desktop.
Save Henrydykee/51f692d9be637763bf1af0bcd0c68f5f to your computer and use it in GitHub Desktop.
crimson-dryad-4262
class StoreObject {
String storeName;
StoreObject(this.storeName);
}
class MyObject {
String property1;
List<StoreObject> property2;
String property3;
MyObject(this.property1, this.property2, this.property3);
}
void main() {
List<MyObject> myObjectList = [];
// Three strings
String string1 = "Hello";
String string3 = "Dart";
// Create MyObject instances and add them to the list
MyObject object1 = MyObject(string1, [StoreObject("mrbigs"),StoreObject("spiderman")], string3);
myObjectList.add(object1);
// You can repeat the process for other strings
// MyObject object2 = MyObject("Another", "Object", "Here");
// myObjectList.add(object2);
// Print the list of objects
// for (MyObject obj in myObjectList) {
// print("Property 1: ${obj.property1}, Property 2: ${obj.property2}, Property 3: ${obj.property3}");
// }
print(myObjectList[0].property2[1].storeName);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment