build method

  1. @override
Widget build(
  1. Context context
)
override

Implementation

@override
Widget build(Context context) {
  final textDirection = this.textDirection ?? Directionality.of(context);
  final iconTheme = Theme.of(context).iconTheme;
  final iconSize = size ?? iconTheme.size;
  final iconColor = color ?? iconTheme.color!;
  final iconOpacity = iconColor.alpha;
  final iconFont = font ?? iconTheme.font;

  Widget iconWidget = RichText(
    textDirection: textDirection,
    text: TextSpan(
      text: String.fromCharCode(icon.codePoint),
      style: TextStyle.defaultStyle().copyWith(
        color: iconColor,
        fontSize: iconSize,
        fontNormal: iconFont,
      ),
    ),
  );

  if (icon.matchTextDirection) {
    switch (textDirection) {
      case TextDirection.rtl:
        iconWidget = Transform(
          transform: Matrix4.identity()..scale(-1.0, 1.0, 1.0),
          alignment: Alignment.center,
          child: iconWidget,
        );
        break;
      case TextDirection.ltr:
        break;
    }
  }

  if (iconOpacity < 1.0) {
    iconWidget = Opacity(
      opacity: iconOpacity,
      child: iconWidget,
    );
  }
  return iconWidget;
}