This repository was archived by the owner on Feb 16, 2026. It is now read-only.
Description I wonder if one can somehow integrate JsonSerializable into json_dynamic_widget.
Currently (at least in my knowledge) it is quite boilerplaty to write an ArgParser for enums:
https://github.com/peiffer-innovations/json_dynamic_widget/blob/main/packages/json_dynamic_widget/doc/CODE_GENERATOR.md#custom-codecs
@JsonArgEncoder ('borderType' )
static String _encodeBorderType (BorderType value) {
var result = 'circle' ;
switch (value) {
case BorderType .Circle :
result = 'circle' ;
break ;
case BorderType .Oval :
result = 'oval' ;
break ;
case BorderType .Rect :
result = 'rect' ;
break ;
case BorderType .RRect :
result = 'rrect' ;
break ;
}
return result;
}
@JsonArgDecoder ('borderType' )
BorderType _decodeBorderType ({
required value,
}) {
var result = BorderType .Circle ;
if (value is String ) {
switch (value) {
case 'circle' :
result = BorderType .Circle ;
break ;
case 'oval' :
result = BorderType .Oval ;
break ;
case 'rect' :
result = BorderType .Rect ;
break ;
case 'rrect' :
result = BorderType .RRect ;
break ;
}
}
return result;
}
Can't we make use of the @JsonValue annotation of json_serializable, if one defines an enum by themselves?
https://pub.dev/packages/json_serializable#enums
enum BorderType {
@JsonValue ('circle' )
Circle ,
@JsonValue ('oval' )
Oval ,
@JsonValue ('rect' )
Rect ,
@JsonValue ('RRect' )
RRect ,
}Reactions are currently unavailable
I wonder if one can somehow integrate JsonSerializable into json_dynamic_widget.
Currently (at least in my knowledge) it is quite boilerplaty to write an ArgParser for
enums:https://github.com/peiffer-innovations/json_dynamic_widget/blob/main/packages/json_dynamic_widget/doc/CODE_GENERATOR.md#custom-codecs
Can't we make use of the
@JsonValueannotation ofjson_serializable, if one defines an enum by themselves?https://pub.dev/packages/json_serializable#enums