Dart – AppDividend https://appdividend.com Latest Code Tutorials Fri, 03 Jan 2020 08:34:34 +0000 en-US hourly 1 https://appdividend.com/wp-content/uploads/2017/08/cropped-ApDivi-32x32.png Dart – AppDividend https://appdividend.com 32 32 Dart List Example | Dart Programming List Tutorial https://appdividend.com/2019/03/17/dart-list-example-dart-programming-list-tutorial/ https://appdividend.com/2019/03/17/dart-list-example-dart-programming-list-tutorial/#respond Sun, 17 Mar 2019 14:10:47 +0000 http://localhost/wordpress/?p=5236

Dart List is the ordered group of objects. The dart: core library provides a List class that enables the creation and manipulation of lists. The very commonly used collection in programming is an array. Dart represents the arrays in the form of List objects. A unique number called the index identifies each element in the List. An index […]

The post Dart List Example | Dart Programming List Tutorial appeared first on AppDividend.

]]>

Dart List is the ordered group of objects. The dart: core library provides a List class that enables the creation and manipulation of lists. The very commonly used collection in programming is an array. Dart represents the arrays in the form of List objects. A unique number called the index identifies each element in the List. An index starts from zero and extends up to n-1 where n is a total number of items in the List.

## Dart List Example

Lists can be classified into two types.

• Fixed Length List
• Growable List

## Fixed Length List

A fixed-length list’s length cannot change at runtime.

The syntax for creating the fixed-length list is as given below.

`var list_name = new List(initial_size)`

Let’s see the following example.

```// app.dart

void main() {
var initial_size = 5;
var app_list = new List(initial_size);
app_list[0] = 'Krunal';
app_list[1] = 'Ankit';
app_list[2] = 'Rushabh';
app_list[3] = 'Dhaval';
app_list[4] = 'Nehal';

print(app_list);
}
```

Let’s see the output inside the terminal.

## Growable List

The growable list’s length can change at the run-time.

The syntax for declaring and initializing a growable list is as given below.

`var list_name = new List()`

Let’s see the following example.

```// app.dart

void main() {
var app_list = [19, 21, 46];
print(app_list);
}
```

See the following output.

We can check the length of the List using the length function.

```// app.dart

void main() {
var app_list = [19, 21, 46];
print(app_list.length);
}
```

See the output.

## Dart List Properties

We have seen one List property called length. Some other properties of List are the following.

### First

This property returns the first element in the list.

```// app.dart

void main() {
var app_list = [19, 21, 46];
print(app_list.first);
}
```

See the output.

You can find more properties on official documentation.

Finally, Dart List Example is over.

The post Dart List Example | Dart Programming List Tutorial appeared first on AppDividend.

]]>
https://appdividend.com/2019/03/17/dart-list-example-dart-programming-list-tutorial/feed/ 0