boxchecker/lib/data_util.dart

46 lines
1.1 KiB
Dart

enum Page { lists, templates }
class List {
List(this.id, this.name, {this.isTemplate});
int id;
String name;
bool? isTemplate;
Map<String, dynamic> toMap() {
var map = Map<String, dynamic>();
map["id"] = this.id;
map["list_name"] = this.name;
if (isTemplate != null) map["is_template"] = this.isTemplate as int;
return map;
}
static List fromMap(Map<String, dynamic> map) {
return List(map["id"], map["list_name"],
isTemplate: map["is_template"] == 1);
}
}
class Check {
Check(this.id, this.text, this.value, {this.listID});
int id;
String text;
bool value;
int? listID;
Map<String, dynamic> toMap() {
var map = Map<String, dynamic>();
map["id"] = this.id;
map["check_text"] = this.text;
map["value"] = this.value as int;
if (listID != null) map["list_id"] = this.listID as int;
return map;
}
static Check fromMap(Map<String, dynamic> map) {
return Check(map["id"], map["check_text"], map["value"] == 1,
listID: map["list_id"]);
}
}