register<T> method

Future<Box<T>> register<T>(
  1. String key,
  2. TypeAdapter<T> adapter
)

Registers a type adapter to a key and opens the box for the objects. Boxes must initlaly be registered before used

Implementation

Future<Box<T>> register<T>(String key, TypeAdapter<T> adapter) async {

  //Registers the storage system in flutter
  if(openBoxes.isEmpty){
    await init();
  }

  if(openBoxes[key] == null){
    //register the adapter if it is not registered
    registerAdapter(adapter);
  }

  //Returns the open box
  return await storeBox<T>(key);

}