boolean function

dynamic boolean(
  1. dynamic intOrBool, {
  2. bool isInt = true,
})

Normalizes a SQLite boolean value.

  • When isInt is true, intOrBool is expected to be 0/1 and a corresponding bool is returned.
  • When isInt is false, intOrBool is returned as is.
  • null is passed through.

Implementation

dynamic boolean(dynamic intOrBool, {bool isInt = true}) {
  if (intOrBool == null) return null;
  if (isInt) return (intOrBool as num) > 0;
  return intOrBool as bool;
}