I am familiar with switch case statements, but not so with switch statement. Is it a new feature added to dart? What does it really do? Here is the code snippet.
Map.fromEntries(
inputMap.entries.map(
(e) {
return MapEntry(
e.key,
switch (e.value) {
DateTime t => toJsonDateTime(t),
Duration d => toJsonDuration(d),
Enum t => t.name,
_ => e.value,
});
},
),
),
New contributor
M99Coder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.