setIconWithText method

Widget setIconWithText({
  1. required String label,
  2. String? email,
  3. String? icon,
  4. String? fontFamily,
  5. double iconSize = 20,
  6. double? fontSize,
  7. double? horizontalSpace,
  8. Color iconColor = Colors.black,
  9. Color textColor = Colors.black,
  10. int maxLines = 2,
})

Creates an icon-text combination widget with horizontal layout.

Displays an icon (from assets) followed by text in an expandable row. Useful for contact information, feature lists, or labeled icons.

Parameters:

  • label: The text to display next to the icon.
  • email: Optional email parameter (currently unused in implementation).
  • icon: Path to the asset image for the icon.
  • fontFamily: Font family for the text. Defaults to Utils.appConstants.regularFontFamily.
  • iconSize: Size of the icon (defaults to 20).
  • fontSize: Font size for the text. Defaults to Utils.appConstants.normalFontSize.
  • horizontalSpace: Spacing between icon and text. Defaults to Utils.appConstants.zeroPointZeroOne.
  • iconColor: Tint color for the icon (defaults to black).
  • textColor: Color for the label text (defaults to black).
  • maxLines: Maximum number of lines for the text (defaults to 2).

Returns an Expanded widget containing the icon and text row.

Example:

setIconWithText(
  label: 'contact@example.com',
  icon: 'assets/icons/email.png',
  iconColor: Colors.blue,
  maxLines: 1,
);

Implementation

Widget setIconWithText(
    {required String label,
    String? email,
    String? icon,
    String? fontFamily,
    double iconSize = 20,
    double? fontSize,
    double? horizontalSpace,
    Color iconColor = Colors.black,
    Color textColor = Colors.black,
    int maxLines = 2}) {
  return Expanded(
    child: Row(
      children: [
        ImageIcon(
          AssetImage(icon!),
          size: iconSize,
          color: iconColor,
        ),
        addHorizontalSpace(
            horizontalSpace ?? Utils.appConstants.zeroPointZeroOne),
        Expanded(
          child: Text(
            label,
            overflow: TextOverflow.ellipsis,
            maxLines: maxLines,
            style: TextStyle(
                fontFamily:
                    fontFamily ?? Utils.appConstants.regularFontFamily,
                color: textColor,
                fontSize: fontSize ?? Utils.appConstants.normalFontSize),
          ),
        ),
      ],
    ),
  );
}