diff --git a/experiment/container/example1/bin/main.dart b/experiment/container/example1/bin/main.dart index 76569588..47ecf359 100644 --- a/experiment/container/example1/bin/main.dart +++ b/experiment/container/example1/bin/main.dart @@ -1,4 +1,5 @@ import 'dart:mirrors'; +import 'package:example1/src/models.dart'; void main() { final stopwatch = Stopwatch()..start(); @@ -14,15 +15,23 @@ void main() { printAnnotationValue(String); printAnnotationValue(Shape); + printAnnotationValue(Square); } class Shape { void draw() => print("Draw Shape"); } +@Person('Will', 'Tom') +class Square { + void greetHii() { + print("Hii Welcome to flutter agency"); + } +} + void printAnnotationValue(final Type clazz) { final DeclarationMirror clazzDeclaration = reflectClass(clazz); - final ClassMirror someAnnotationMirror = reflectClass(Shape); + final ClassMirror someAnnotationMirror = reflectClass(Person); final annotationInstsanceMirror = clazzDeclaration.metadata.where((d) => d.type == someAnnotationMirror); if (annotationInstsanceMirror.isEmpty) { @@ -30,6 +39,6 @@ void printAnnotationValue(final Type clazz) { return; } final someAnnotationInstance = - (annotationInstsanceMirror.first.reflectee as Shape); - print("${someAnnotationInstance.draw}"); + (annotationInstsanceMirror.first.reflectee as Person); + print(someAnnotationInstance.firstName); } diff --git a/experiment/container/example1/lib/src/models.dart b/experiment/container/example1/lib/src/models.dart new file mode 100644 index 00000000..abc1b6d8 --- /dev/null +++ b/experiment/container/example1/lib/src/models.dart @@ -0,0 +1,5 @@ +class Person { + final String firstName; + final String lastName; + const Person(this.firstName, this.lastName); +}