reflectable_annotation 1.0.1 copy "reflectable_annotation: ^1.0.1" to clipboard
reflectable_annotation: ^1.0.1 copied to clipboard

discontinued

This package provides a single annotation with all capabilities of Reflectable.dart

example/reflectable_annotation_example.dart

import 'package:reflectable_annotation/reflectable_annotation.dart';
// IMPORTANT: @GlobalQuantifyMetaCapability must annotated on reflectable package import
@GlobalQuantifyCapability("^.HumanFriendly", reflected)
@GlobalQuantifyMetaCapability(MyAnnotation, reflected)
import 'package:reflectable/reflectable.dart';

import 'reflectable_annotation_example.reflectable.dart';

class MyAnnotation {
  const MyAnnotation();
}

abstract class HumanFriendly {}

class Animal {}

@MyAnnotation()
class Dog extends Animal implements HumanFriendly {}

main() {
  initializeReflectable();

  assert(reflected.canReflectType(Animal));
  assert(reflected.canReflectType(Dog));
  assert(reflected.canReflectType(HumanFriendly));

  ClassMirror dogClassMirror = reflected.reflectType(Dog);
  ClassMirror animalClassMirror = reflected.reflectType(Animal);
  ClassMirror humanFriendlyClassMirror = reflected.reflectType(HumanFriendly);

  assert(dogClassMirror.newInstance("", []) is Dog);
  assert(animalClassMirror.newInstance("", []) is Animal);
  assert(dogClassMirror.isSubclassOf(animalClassMirror));
  assert(dogClassMirror.isAssignableTo(animalClassMirror));
  assert(dogClassMirror.isAssignableTo(animalClassMirror));
  assert(dogClassMirror.isAssignableTo(humanFriendlyClassMirror));
}
0
likes
40
pub points
0%
popularity

Publisher

unverified uploader

This package provides a single annotation with all capabilities of Reflectable.dart

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

reflectable

More

Packages that depend on reflectable_annotation