Last active
March 26, 2020 19:24
-
-
Save tailorvj/c1d1392555739af7fab246fe0df569b6 to your computer and use it in GitHub Desktop.
Dart list variable type example
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
main() { | |
List list = [1,'two',3,'four']; | |
print('list.length is ${list.length}'); | |
print('list: $list'); | |
print('list index 1 value: ${list[1]}'); | |
print('list index 0 value: ${list[0]}\n'); | |
print('Adding 10 to the end of the list'); | |
list.add(10); | |
print('list: $list\n'); | |
print('Removing the value 3 from the list'); | |
list.remove(3); | |
print('list: $list\n'); | |
print('Removing the first item from the list'); | |
list.removeAt(0); | |
print('list: $list\n'); | |
print('Removing the last item from the list'); | |
list.removeLast(); // | |
print('list: $list\n'); | |
print('Adding an item to the beginning of the list'); | |
list.insert(0,'one'); | |
print('list: $list'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment