Basic operation of Array in dart

Dart for beginners part - 2

Tony Wilson jesuraj
3 min readNov 1, 2021

This blog will cover some basic concept of Array and sets in dart

Dart for beginners part- 1 (about variables)

basically

  • Array is used to represent a collection of values. It can have some duplicate values
  • Sets also represent a collection of values. But it cannot have any duplicate value with it

Syntax of Sets

only {} make some difference rest all same like array

syntax of Array

For getting length of the List

For in loop

we can use normal for loop to

Okay let’s get into some basic operation of list

Basic operation in list

To find its Empty or not

.isEmpty is used, If list have value will return False otherwise True

.isNotEmpty is opposite to .isEmpty

To print first index value

.first is used

For last .last

Note: if array is empty .first and .last will throw error

To add a value

.add("The value want to add") , Will append in last

To add in specific place

we use .insert(index, "Value")

To remove

.remove(indexplace)

To clear all

.clear() , will remove all the values in array

To search

To get index of specific value

Last but not least

this Array can also have any data type, Like

To avoid these we need to specify the data type while declaring. Like

concatenating arrays

If condition in Array

condition is true so we get Thor inside the array,

For loop in the Array

If any mistake or you need to shout me, comments session in always opened

other blogs - dart for beginners

நன்றி வணக்கம் || Thank you

--

--