1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-30 06:56:10 +00:00

Background + clean

This commit is contained in:
Yan Maniez 2020-03-01 21:30:33 +01:00
parent 28fd23b2d1
commit dece242a54
3 changed files with 169 additions and 82 deletions

View file

@ -118,3 +118,26 @@ Future<List<SubRaceItem>> loadSubRaces(RaceItem race) async {
}
return null;
}
Future<List<T>> loadTypedItems<T extends Item>({String itemType, Item item = null}) async {
final db = await database;
var response = await db.query(
"Items",
where: "ItemType = ?" + (item != null ? " AND ParentLink = ?" : ""),
whereArgs: item != null ? [itemType, item.id] : [itemType],
orderBy: "NormalizedName"
);
if (response.isNotEmpty) {
return itemsFromMapList(response);
}
return null;
}
Future<List<BackgroundItem>> loadBackgrounds() async {
return loadTypedItems<BackgroundItem>(itemType: "BackgroundItem");
}
Future<List<SubBackgroundItem>> loadSubBackgrounds(Item item) async {
return loadTypedItems<SubBackgroundItem>(itemType: "SubBackgroundItem", item: item);
}