I'm making a library for persistence implementation. For that I want to use reflection to be able to restore an object from the storage. I can't use dart:mirrors because this library will be use also in Flutter application. So I'm trying to use reflectable package. And here I'm getting a major issue with understanding of how it should work. The doc tells reflectable uses build package and that some files must be generated. But I couldn't find anywhere whether this generation should happen for each file in my library package or just those where reflectable is used.

My library project structure is standard:

/examples
/lib
/lib/src
/lib/my_package.dart
/test
/pubspec.yaml

When I run dart run build_runner or dart run build_runner lib from the project root I see for each file in /example and /tests a matching file is generated. But in /lib folder nothing is generated. Only file where I'm intending to use reflectable is /lib/src/persistence/persistence_model.dart. I've created a file /lib/build.yaml of following content:

targets:
  $default:
    builders:
      reflectable:
        generate_for:
          - src/persistence/persistence_model.dart
        options:
          formatted: true

but it seems to have no effect.

So, what should be right approach?

And probably a side question or rather consideration: isn't using reflection in Dart and Flutter excessively complex comparing to other languages (Python, C#, Java)?