Chapter 7. Reflection

What is reflection? For our purposes, reflection is the ability of a program to examine or modify itself. Reflection can be further subdivided into introspection, the ability of a program to determine its structure while running, and self-modification, its ability to change itself while running.

At this time, Dart only supports introspection. We expect support for self-modification to evolve over time.

Reflection in Dart is based on the concept of mirrors. A mirror, in this context, is an object that reflects another object. Mirrors are a particular form of reflective APIs that have advantages with respect to distribution, deployment and security, which we will discuss in depth in Section 7.2. First, we’ll build up an understanding ...

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.