Find first in Dart

Find this useful? Support us: Star on GitHub 6
Category: Array | Language: Dart

To find the first element of an array in Dart, you can use the first property. Here is an example:

void main() {
  List numbers = [1, 2, 3, 4, 5];
  int firstNumber = numbers.first;
  print('The first number in the array is $firstNumber'); // Output: The first number in the array is 1
}

In the example above, we define an array of integers called numbers. We then use the first property to get the first element in the array and assign it to the variable firstNumber. We then print the value of firstNumber. The output will be The first number in the array is 1.