addIfVAndNew method
addIfVAndNew adds a key value pair to a Map if the key and value are not
null and if the key doesn't already exist.
bToInt
transforms a bool value to an int (0 or 1).
iToStr
transforms an int value to a String.
Returns true if pair is added.
Implementation
bool addIfVAndNew(
dynamic key,
dynamic value, {
bToInt = true,
iToStr = true,
}) {
if (key == null || value == null || containsKey(key)) {
return (false);
}
dynamic v = value;
if (bToInt && value is bool) {
v = value ? 1 : 0;
}
if (iToStr && v is int) {
v = v.toString();
}
this[key] = v;
return (true);
}