saveToCollection<T> method

Future saveToCollection<T>(
  1. String key, {
  2. bool inBackpack = false,
})
inherited

Save an item to a collection E.g. List of numbers

User userAnthony = new User(name: 'Anthony'); await userAnthony.saveToCollection('mystoragekey');

User userKyle = new User(name: 'Kyle'); await userKyle.saveToCollection('mystoragekey');

Get the collection back with the user included. List

The key is the collection you want to access, you can also save the collection to the Backpack class.

Implementation

Future saveToCollection<T>(String key, {bool inBackpack = false}) async {
  await NyStorage.addToCollection<T>(key, item: this);
  if (inBackpack == true) {
    Backpack.instance.set(key, this);
  }
}