proxiable 1.0.0
proxiable: ^1.0.0

Dart native js
Flutter Android iOS web

Proxy provides static methods for creating dynamic proxy classes and instances, and it is also the superclass of all dynamic proxy classes created by those methods.

Proxiable #

Proxy provides static methods for creating dynamic proxy classes and instances, and it is also the superclass of all dynamic proxy classes created by those methods.

Read More #

Java Proxy Class

Provided Features #

Proxy.newProxyInstance: creates proxy instance, slightly different from java Proxy.

InvocationHandler: contract that your handler should implements;

DefaultInvocationHandler: it calls original method, getter or setter.

Usage #

1. Initialization in main.dart

You do NOT need to initialize reflectable.

// file: main.dart
import "main.proxiable.dart";

void main() {
  initializeProxiable();
}

2. Create and use Proxied instance

// file: main.dart
import "package:proxiable/proxiable.dart";

// mark the class with @proxiable is required
@proxiable
class Animal {
  void walk() {
    print("Animal is waling.");
  }
}

void main() {
  Animal animal = Proxiable(
    Animal,
    DefaultInvocationHandler(Animal()),
  );
  animal.walk(); // print: Animal is waling.
}
1
likes
80
pub points
0%
popularity

Proxy provides static methods for creating dynamic proxy classes and instances, and it is also the superclass of all dynamic proxy classes created by those methods.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

cpdg128@gmail.com

License

MIT (LICENSE)

Dependencies

build, exporter, matchable_builder, reflectable, reflectable_annotation

More

Packages that depend on proxiable