createEffect static method

VoidCallback createEffect(
  1. Function fn
)

Creates an effect based on a provided function. The provided function will be called whenever one of its dependencies change.

Example:

final age = Beacon.writable(15);

Beacon.createEffect(() {
    if (age.value >= 18) {
      print("You can vote!");
    } else {
       print("You can't vote yet");
    }
 });
});

// Outputs: "You can't vote yet"

age.value = 20; // Outputs: "You can vote!"

Implementation

static VoidCallback createEffect(Function fn) {
  return effect(fn);
}