asBoolMap method
Implementation
Map<String, bool> asBoolMap({String? id}) {
if (type == FieldType.bool) {
if (id != null) {
// Return a single subvalue. We're checking if it exists.
final item = values.firstWhereOrNull((data) => data.id == id);
if (item == null) return {};
return {item.id: item.active};
} else {
// We're going to merge this all together into one long string of values
Map<String, bool> myMap = {
for (var item in values) item.id: item.active
};
return myMap;
}
} else if (type == FieldType.string) {
if (id != null) {
// Return a single subvalue. We're checking if it exists.
final item = values.firstWhereOrNull((data) => data.id == id);
if (item == null) return {};
return {item.value ?? item.id: item.value != "" ? true : false};
} else {
// We're going to merge this all together into one long string of values
Map<String, bool> myMap = {
for (var item in values)
item.value ?? item.id: item.value != "" ? true : false
};
return myMap;
}
}
return {};
}