boolean static method
bool values
Implementation
static CustomLayout<int, bool> boolean({
String? property,
Layout<int>? layout,
int falseFlag = 0,
int trueFlag = 1,
}) {
return CustomLayout<int, bool>(
layout: layout ?? u8(),
decoder: (data) {
if (data != falseFlag && data != trueFlag) {
throw BuError(
DefaultErrorType.invalidArgument,
"Failed to decode data as boolean.",
details: {"value": data.toString(), "property": property},
);
}
return data == falseFlag ? false : true;
},
encoder: (src) {
return src ? trueFlag : falseFlag;
},
property: property,
);
}