In Dart, is there a way to intercept accesses and mutations to programming constructs? In Dart, is there a way to intercept accesses and mutations to programming constructs? dart dart

In Dart, is there a way to intercept accesses and mutations to programming constructs?


You can not do that at runtime for now. You could perhaps do something like this once mirror builders has landed. From Reflection in Dart with Mirrors: An Introduction

We’d like to support more powerful reflective features in the future. These would include mirror builders, designed to allow programs to extend and modify themselves, and a mirror-based debugging API as well.

However you can do that at built-time either in a pre-processor (like a build.dart) or with a pub transformer. You also use the analyzer package to get the AST if you need it. This can be seen like APT in Java.