toMap function

Map<String, dynamic> toMap(
  1. dynamic value, {
  2. Map<String, dynamic>? defaultValue,
})

Implementation

Map<String, dynamic> toMap(value, {Map<String, dynamic>? defaultValue}) {
  if (value == null) return defaultValue ?? <String, dynamic>{};
  if (value is Map || value is Map<String, dynamic>) {
    return Map<String, dynamic>.from(value);
  }
  return defaultValue ?? <String, dynamic>{};
}