setIconWithText method
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 toUtils.appConstants.regularFontFamily.iconSize: Size of the icon (defaults to 20).fontSize: Font size for the text. Defaults toUtils.appConstants.normalFontSize.horizontalSpace: Spacing between icon and text. Defaults toUtils.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),
),
),
],
),
);
}