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 "
Last active
March 20, 2023 07:07
-
-
Save sdkdeepa/fcf4007a9b5711af61d4da6a1c446907 to your computer and use it in GitHub Desktop.
Lists in Dart
This file contains hidden or 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
// 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