create method

void create(
  1. StoreToken token, {
  2. bool recreate = false,
})

Initializes the Store

set recreate = true to make it recreateable

Implementation

void create(StoreToken token, {bool recreate = false}) {
  if (_uninitialized.containsKey(token))
    try {
      _initialized[token] = _uninitialized[token]!.call();
      if (recreate) _reusable[token] = _uninitialized[token]!;
      _uninitialized.remove(token);
    } catch (e) {
      print("Exception occured when tried initializing the store");
      print("StoreToken: $token");
      rethrow;
    }
  else {
    if (_disposed.containsKey(token))
      throw Exception("Token expired. It has already been disposed");
    else
      throw Exception("Token doesn't exist.");
  }
}