Generator Functions

In this lesson, you will learn about the generator functions.

Introduction

Dart Generator Functions are used to generate a sequence of values on-demand in a lazy manner. Such a value sequence can be generated either synchronously or asynchronously. There are two types of built-in generator functions available to support both scenarios:

  • Synchronous Generator: The synchronous generator function returns an Iterable object. That means the values are generated first and then returned lazily on-demand by the function.

Iterable: A collection of values or “elements”, that can be accessed sequentially. ...