fromMap static method
- Map<
String, dynamic> ? map, { - EnumMethod? enumMethod,
Gets a possible WebMessage instance from a Map value.
Implementation
static WebMessage? fromMap(
Map<String, dynamic>? map, {
EnumMethod? enumMethod,
}) {
if (map == null) {
return null;
}
final instance = WebMessage(
data: map['data'],
ports: map['ports'] != null
? List<IWebMessagePort>.from(map['ports'].map((e) => e))
: null,
type: switch (enumMethod ?? EnumMethod.nativeValue) {
EnumMethod.nativeValue => WebMessageType.fromNativeValue(map['type']),
EnumMethod.value => WebMessageType.fromValue(map['type']),
EnumMethod.name => WebMessageType.byName(map['type']),
}!,
);
return instance;
}