Dart Runes isEmpty
Syntax & Examples

Runes.isEmpty property

The `isEmpty` property in Dart checks if there are no elements in the sequence of Unicode code points.


Syntax of Runes.isEmpty

The syntax of Runes.isEmpty property is:

 bool isEmpty 

This isEmpty property of Runes returns true if there are no elements in this collection.

Return Type

Runes.isEmpty returns value of type bool.



✐ Examples

1 Check if sequence is empty

In this example,

  1. We create an empty sequence of Unicode code points emptyRunes.
  2. We use the isEmpty property to check if it is empty.
  3. We then print the result to standard output.

Dart Program

void main() {
  Runes emptyRunes = Runes('');
  bool isEmpty = emptyRunes.isEmpty;
  print('Is sequence empty? $isEmpty');
}

Output

Is sequence empty? true

2 Check if non-empty sequence is empty

In this example,

  1. We create a non-empty sequence of Unicode code points nonEmptyRunes from the string 'Hello'.
  2. We use the isEmpty property to check if it is empty.
  3. We then print the result to standard output.

Dart Program

void main() {
  Runes nonEmptyRunes = Runes('Hello');
  bool isNotEmpty = nonEmptyRunes.isEmpty;
  print('Is sequence empty? $isNotEmpty');
}

Output

Is sequence empty? false

Summary

In this Dart tutorial, we learned about isEmpty property of Runes: the syntax and few working examples with output and detailed explanation for each example.