toJson method

Map<String, dynamic> toJson()
override

Implementation

Map<String, dynamic> toJson() {
  final json = super.toJson();
  final defaultColor = () {
    final b = WidgetsBinding.instance!.window.platformBrightness;
    switch (b) {
      case Brightness.dark:
        return Colors.white;
      default:
        return Colors.black;
    }
  }();
  final style = _copyStylesWithin(
    TextStyle(fontSize: 14, color: defaultColor),
    this.style,
  )!;
  json.addAll({
    'textColor': style.color?.toHex(),
    'textSize': style.fontSize,
    'text': text,
    'letterSpacing': style.letterSpacing,
    'minLines': minLines ?? 1,
    'maxLines': maxLines,
    'bold': style.fontWeight == FontWeight.bold,
  });
  return json;
}