fromJson static method
Implementation
static GuideAction fromJson(Map<String, dynamic> json) {
final legacyType = _normalizedLegacyActionType(
optString(json, 'type', 'dismiss'),
);
final url = _optStringOrNull(json, 'url');
final onClick = optMap(json, 'onClick');
final actions = onClick != null
? const EngageActionParser().parse(onClick)
: _legacyEngageActions(legacyType, url);
return GuideAction(
label: optString(json, 'label'),
style: _styleFrom(optString(json, 'style', 'primary')),
actions: actions,
analyticsType: actions.isEmpty ? legacyType : actions.first.analyticsType,
backgroundColor: _color(json, 'backgroundColor'),
textColor: _color(json, 'textColor'),
fontSize: _positive(json['fontSize'], 13),
fontWeight: _weight(
json['fontWeight'],
fallback: FontWeight.w600,
),
cornerRadius: _nonNegative(json['cornerRadius'], 8),
padding: _edges(
json['padding'],
const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
),
margin: json.containsKey('margin')
? _edges(json['margin'], EdgeInsets.zero)
: null,
);
}