parseBool method

bool parseBool(
  1. dynamic value, {
  2. bool isVideoMutedChanged = false,
})

Required because Android SDK returns boolean values as Strings and iOS SDK returns boolean values as Booleans. (Making this an extension does not work, because of dynamic.)

Implementation

bool parseBool(dynamic value, {bool isVideoMutedChanged = false}) {
  if (value is bool) return value;
  if (isVideoMutedChanged && value is String) {
    return value != '0.0';
  }

  if (value is String) return value == 'true';
  if (value is num) return value != 0;

  throw ArgumentError('Unsupported type: $value');
}