Skip to content

Instantly share code, notes, and snippets.

@tailorvj
Last active March 26, 2020 19:24
Show Gist options
  • Save tailorvj/c1d1392555739af7fab246fe0df569b6 to your computer and use it in GitHub Desktop.
Save tailorvj/c1d1392555739af7fab246fe0df569b6 to your computer and use it in GitHub Desktop.
Dart list variable type example
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