Chapter 4. Functions

Functions are the workhorse of Dart. It is functions that actually compute things. We use the term functions loosely to cover functions and methods of all syntactic forms, regardless of whether they behave as mathematical functions or not.

Functions in Dart are first class values that can be stored in variables, passed as parameters and returned as results. Like all runtime values in Dart, functions are objects.

We have already encountered a variety of functions: top-level functions, instance and class methods (be they getters, setters, operators or vanilla methods) and constructors. As we shall see, there are also local functions and function literals. They all share common structure which we will illustrate here.

4.1 Parameters ...

Get The Dart Programming Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.