toBooleanN static method

bool? toBooleanN(
  1. dynamic d
)

Converts a dynamic value to a nullable boolean.

d - The dynamic value to be converted. Returns a boolean if the conversion is successful, otherwise null.

Implementation

static bool? toBooleanN(dynamic d) {
  if (d is bool) {
    return d;
  }
  if (d is String) {
    return d.toLowerCase() == 'true';
  }
  return null;
}