looseBool function

bool? looseBool(
  1. Object? value
)

A bool from a bool or the strings "true" / "false"; null otherwise.

Implementation

bool? looseBool(Object? value) => switch (value) {
      bool b => b,
      String s when s.trim().toLowerCase() == 'true' => true,
      String s when s.trim().toLowerCase() == 'false' => false,
      _ => null,
    };