You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to suggest you having a look at this package. It has a simpler way to serialize/deserialize enum classes. Instead of manually listing all the values, we can just do something like:
I would like to suggest you having a look at this package. It has a simpler way to serialize/deserialize enum classes. Instead of manually listing all the values, we can just do something like:
extension FontWeightToJson on FontWeight {
String toJson() {
return this.toString().stripFirstDot();
}
}
this is an extension method that will strip the class name for you.
And for parsing, you can just use:
FontWeight? parseFontWeight(String? string) {
FontWeight? rst;
FontWeight.values.forEach((element) {
if (string == element.toJson()) {
rst = element;
}
});
return rst;
}
What do you think?
The text was updated successfully, but these errors were encountered: