toJson method
Abstract function that concrete classes must implement. This must encode the internal data model to a JSON compatible representation.
While not required, it is suggested to call removeNull before returning.
Implementation
@override
Map<String, dynamic> toJson() {
final jsonWidgetArgs = this.jsonWidgetArgs;
return JsonClass.removeNull({
'type': jsonWidgetType,
// Skips the id if it's a valid (auto generated) UUID to avoid spamming
// the emitted JSON
'id': Uuid.isValidUUID(fromString: jsonWidgetId) ? null : jsonWidgetId,
'listen':
jsonWidgetListenVariables.isEmpty
? null
: List<String>.from(jsonWidgetListenVariables),
'args':
jsonWidgetArgs is JsonClass
? jsonWidgetArgs.toJson()
: jsonWidgetArgs,
});
}