Skip to content

Instantly share code, notes, and snippets.

@sdkdeepa
Last active March 20, 2023 07:07
Show Gist options
  • Save sdkdeepa/fcf4007a9b5711af61d4da6a1c446907 to your computer and use it in GitHub Desktop.
Save sdkdeepa/fcf4007a9b5711af61d4da6a1c446907 to your computer and use it in GitHub Desktop.
Lists in Dart

Lists in Dart

Lists are like JavaScript Array. You can create a create them with different types. However, if you want to create for a specific type then you could specify as " List "

// Lists are like arrays in JS
// void main() {
// List names = ['Deepa', 'Andy', 'Stacy'];
// names.add('Raj');
// names.remove('Stacy');
// names.add(576);
// print(names);
// }
// output --->>> [Deepa, Andy, Raj, 576]
// For creating list of string we need to specify the type as String, int etc
void main() {
List<String> names = ['Deepa', 'Andy', 'Stacy'];
names.add('Raj');
names.remove('Stacy');
// names.add(576); will throw an error
print(names);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment