built_mirrors

Build Status

This is a library that generates ClassMirror from classes annotated with @reflectable or @Reflectable().

Getting Started

1. Create a new dart-web project. 2. add built_mirrors dependency to your pubspec.yaml.

...
dependencies:
  ...
  # replace for the latest version
  built_mirrors: any
  ...
dev_dependencies:
  ...
  # replace for the latest version
  built_runner: any
  ...

3. create a file in bin folder called models.dart and put next code on it:

{@example example/bin/models.dart}

4. edit the file main.dart in the folder bin and put next code on it:

{@example example/bin/main.dart}

5. run pub run build_runner build. Then you will see that the files bin/models.g.dart and bin/main.g.dart have been generated and they will contain the next code:

{@example example/bin/main.g.dart}

and:

{@example example/bin/models.g.dart}

6. Finally you can run the file bin/main.dart and if everything is ok you will see next output in console:

p1Fields['myDynamic'].type: dynamic

p1Fields['cars'].type: [List, Car]

car1:
	id: 1
	engine: v8


--------------------------
reflecting "ClassWithMethod"
--------------------------
(someMethod, someMethodWithNamedParams)
dynamic
[Instance of '_MyOtherAnnotation']
[DeclarationMirror on someParameter]
[Instance of '_MyOtherAnnotation']
String

--------------------------
reflecting "someFunction"
--------------------------
someFunction
String
[Instance of 'AnnotationWithFunction']
[DeclarationMirror on p1, DeclarationMirror on p0, DeclarationMirror on p2]
[Instance of '_MyOtherAnnotation']
int
p1
p0
p2

Libraries

builder
built_mirrors_core
init_mirrors_generator
mirrors_generator
scanners