l.bool()
Passes when the value is a bool. Returns a BoolValidator<bool?>. Strings such as 'true' fail. To require true rather than any bool, add a custom validator.
Signature
Section titled “Signature”BoolValidator<bool?> bool({String? message, MessageBuilder? messageBuilder})Parameters
Section titled “Parameters”| Parameter | Type | Meaning |
|---|---|---|
message |
String? |
Replaces the default error message. |
messageBuilder |
MessageBuilder? |
Builds the message from the issue. message wins when both are given. See Message builders. |
Code invalidType. Default message: value must be a bool. value is replaced by the field name when there is one.
Code generation
Section titled “Code generation”A bool parameter maps to l.bool().
Example
Section titled “Example”final flag = l.bool();required bool acceptedTerms, // l.bool().required()flag.validate(input)+2-1- valid:
true - valid:
false - invalid:
'true'