toMap method

Map<String, dynamic> toMap({
  1. EnumMethod? enumMethod,
})

Converts instance to a map.

Implementation

Map<String, dynamic> toMap({EnumMethod? enumMethod}) {
  return {
    "action": switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue => action?.toNativeValue(),
      EnumMethod.value => action?.toValue(),
      EnumMethod.name => action?.name(),
    },
    "resources": resources
        .map(
          (e) => switch (enumMethod ?? EnumMethod.nativeValue) {
            EnumMethod.nativeValue => e.toNativeValue(),
            EnumMethod.value => e.toValue(),
            EnumMethod.name => e.name(),
          },
        )
        .toList(),
  };
}