Skip to content

Latest commit

 

History

History
94 lines (74 loc) · 2.07 KB

_README.adoc

File metadata and controls

94 lines (74 loc) · 2.07 KB

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:

link:example/bin/models.dart[role=include]

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

link:example/bin/main.dart[role=include]

5 - run dart 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:

link:example/bin/main.g.dart[role=include]

and:

link:example/bin/models.g.dart[role=include]

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