getPropsBool function

bool getPropsBool(
  1. Map<String, dynamic> props,
  2. String key, [
  3. bool defaultValue = false
])

Extracts a bool value from props.

Handles bool, int (0/1), and String ('true'/'false') representations.

Implementation

bool getPropsBool(
  Map<String, dynamic> props,
  String key, [
  bool defaultValue = false,
]) {
  final value = props[key];
  if (value is bool) return value;
  if (value is int) return value != 0;
  if (value is String) {
    return value.toLowerCase() == 'true' || value == '1';
  }
  return defaultValue;
}