createSpan method

  1. @override
InlineSpan createSpan({
  1. required BuildContext context,
  2. String? text,
  3. String? textContent,
  4. List<InlineSpan>? children,
  5. required Map<String?, String?> attributes,
  6. GestureRecognizer? recognizer,
})
override

Implementation

@override
InlineSpan createSpan({
  required BuildContext context,
  String? text,
  String? textContent,
  List<InlineSpan>? children,
  required Map<String?, String?> attributes,
  GestureRecognizer? recognizer,
}) {
  Widget iconWidget = Icon(
    icon,
    color: color,
    size: size,
  );
  if (onTap != null) {
    iconWidget = GestureDetector(
      child: iconWidget,
      onTap: () => onTap!(text, attributes),
    );
  }

  /*
  final TextSpan span = TextSpan(
    text: String.fromCharCode(icon.codePoint),
    style: TextStyle(
      fontFamily: icon.fontFamily,
      package: icon.fontPackage,
      color: color,
      fontSize: size,
      backgroundColor: backgroundColor,
    ),
    children: children,
    recognizer: recognizer,
  );
  */

  /*
  final TextSpan span = TextSpan(
    children: [
      WidgetSpan(
        child: iconWidget,
        style: TextStyle(backgroundColor: backgroundColor),
      ),
      if (children != null) ...children,
    ],
  );
  */

  // final InlineSpan span = WidgetSpan(
  //   child: iconWidget,
  //   alignment: alignment,
  //   baseline: baseline,
  //   style: TextStyle(backgroundColor: backgroundColor),
  // );

  final InlineSpan span = TextSpan(
    children: [
      WidgetSpan(
        child: iconWidget,
        alignment: alignment,
        baseline: baseline,
        style: TextStyle(backgroundColor: backgroundColor),
      ),
      /*
      IconSpan(
        icon: icon,
        size: size,
        color: color,
        style: TextStyle(backgroundColor: backgroundColor),
        alignment: alignment,
        baseline: baseline,
        onTap: (onTap != null) ? () => onTap!(text, attributes) : null,
      ),
      */
    ],
  );

  return span;
}