tryParseBool static method

bool? tryParseBool(
  1. dynamic v
)

解析bool,失败返回null

Implementation

static bool? tryParseBool(dynamic v) {
  if (v is bool) {
    return v;
  } else if (v is String) {
    return v == 'true';
  }
  return null;
}