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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.