Dart: Enum to String to Enum

Serialise/Deserialise Dart’s enum with JSON?

String To Enum: In Dart any Object can get converted in String Using toString(). If we convert a enum to string we get somthing “ClassNameOfEnum.valueNameOfEnum”. we can simply spilt string with “.” and map with string to get valid enum. This can be done as following:

--

--

iOS Developer | Swift | Flutter

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store