Implementation
static SpotlightStep? fromJson(Map<String, dynamic> json) {
final anchorKey = optString(json, 'anchorKey');
if (anchorKey.isEmpty) return null;
return SpotlightStep(
anchorKey: anchorKey,
delayInMs:
json.containsKey('delayInMs') ? optInt(json, 'delayInMs', 0) : null,
title: optString(json, 'title'),
body: optString(json, 'body'),
calloutPosition: optString(json, 'calloutPosition', 'below'),
calloutGap: optDouble(json, 'calloutGap', 8),
overlayColor: colorOr(
optString(json, 'overlayColor'),
const Color(0xFF000000),
),
overlayOpacity: optDouble(json, 'overlayOpacity', 0.7),
highlightShape: optString(json, 'highlightShape', 'rect'),
highlightCornerRadius: optDouble(json, 'highlightCornerRadius', 8),
highlightPadding: optDouble(json, 'highlightPadding', 8),
highlightGlowColor: colorOr(
optString(json, 'highlightGlowColor'),
const Color(0x00000000),
),
highlightGlowWidth: optDouble(json, 'highlightGlowWidth', 0),
calloutBackgroundColor: colorOr(
optString(json, 'calloutBackgroundColor'),
const Color(0xFFFFFFFF),
),
calloutCornerRadius: optDouble(json, 'calloutCornerRadius', 8),
calloutMaxWidth: optDouble(json, 'calloutMaxWidth', 280),
calloutPadding: optDouble(json, 'calloutPadding', 12),
calloutShadow: optBool(json, 'calloutShadow', true),
calloutBorderColor: colorOr(
optString(json, 'calloutBorderColor'),
const Color(0x00000000),
),
calloutBorderWidth: optDouble(json, 'calloutBorderWidth', 0),
showArrow: optBool(json, 'showArrow', true),
arrowColor: _color(json, 'arrowColor'),
arrowBorderColor: _color(json, 'arrowBorderColor'),
arrowSize: optDouble(json, 'arrowSize', 8),
titleColor: colorOr(
optString(json, 'titleColor'),
const Color(0xFF111111),
),
titleSize: optDouble(json, 'titleSize', 15),
titleWeight: _weight(optString(json, 'titleWeight', '700')),
bodyColor: colorOr(optString(json, 'bodyColor'), const Color(0xFF444444)),
bodySize: optDouble(json, 'bodySize', 13),
bodyWeight: _weight(optString(json, 'bodyWeight', '400')),
buttonPrimaryBackgroundColor: colorOr(
optString(json, 'buttonPrimaryBackgroundColor'),
const Color(0xFF2563EB),
),
buttonPrimaryTextColor: colorOr(
optString(json, 'buttonPrimaryTextColor'),
const Color(0xFFFFFFFF),
),
buttonGhostTextColor: colorOr(
optString(json, 'buttonGhostTextColor'),
const Color(0xFF2563EB),
),
actions: _actions(json),
);
}