get<T> static method

T get<T>(
  1. String key,
  2. T init()
)

The get method takes the state variable name and its initial value and returns the current value of that variable.

Implementation

static T get<T>(String key, T Function() init) {
  return VComponent.run((vComponent) {
    try {
      final context = VContext(context: vComponent.context, key: _key);
      return context.init(key, init);
    } catch (e, s) {
      throw WrappedException(
          "An error occurred while executing the method '$State.get($key)' for component '$vComponent'",
          e,
          s);
    }
  });
}