I have a Wallpaper App and it uses Firestore to store the wallpapers.
I want to use Hive to store a list of wallpapers from cloud firestore but how to save the List of Wallpapers and retrieve it later?
When I try to save the list I get this error:
E/flutter ( 9995): [ERROR:flutter/shell/common/shell.cc(199)] Dart Error: Unhandled exception: E/flutter ( 9995): HiveError: Cannot write, unknown type: Wallpaper. Did you forget to register an adapter?
Code:
class Wallpaper extends HiveObject {
String date;
String url;
Wallpaper();
}
static Future<void> addWallpapers({@required String boxName, @required List<Wallpaper> wallpapers}) async {
var box = await Hive.openBox(boxName);
box.put(boxName, wallpapers);
print("WALLPAPER ADICIONADO NO HIVE!");
}
static Future<List<Wallpaper>> getWallpapers({@required String boxName}) async {
var box = await Hive.openBox(boxName);
List<Wallpaper> wallpapers = box.get("latest");
return wallpapers;
}