Flutter Reference

Pub Pub Score License

A simple Flutter plugin to keep object in memory on native code, while pass a string reference to Flutter code.

Usefull to interact with native objects without serializing its content.

Usage

From native side, after creating a instance, return it's reference to Flutter using:

val instance = Orange()
val ref = References.add(instance)

To retrieve a instance on native side, use:

val instance = References.get<Orange>(ref)

On Flutter side, always wrap the reference string on Reference class, since this class has capability to handle garbage collection.

Future<Reference> create() {
  return channel.invokeMethod("create").then((value) => Reference(value));
  // or
  return channel.invokeMethodReference("create", (id) => Reference(id));
}

Also you can create your own class who extends Reference

class Fruit extends Reference {
  Fruit(super.id);
}

License

CC BY-ND 4.0

  • You can use and re-dist freely.
  • You can also modify, but only for yourself.
  • You can use it as a part of your project, but without modifications in this project.