You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.2 KiB
97 lines
2.2 KiB
import 'package:flutter/material.dart'; |
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
|
|
class IconText extends StatelessWidget { |
|
final String? leftImage; |
|
final String? rightImage; |
|
final IconData? leftIcon; |
|
final IconData? rightIcon; |
|
final String text; |
|
final TextStyle? textStyle; |
|
final double iconSize; |
|
final double space; |
|
final Color iconColor; |
|
final TextOverflow overFlow; |
|
final CrossAxisAlignment textAxisAlignment; |
|
|
|
final bool isMax; |
|
|
|
IconText(this.text, |
|
{this.leftIcon, |
|
this.rightIcon, |
|
this.leftImage, |
|
this.rightImage, |
|
this.isMax = false, |
|
this.iconSize = 16, |
|
this.space = 1, |
|
this.overFlow = TextOverflow.fade, |
|
this.textAxisAlignment = CrossAxisAlignment.center, |
|
this.iconColor = Colors.black, |
|
this.textStyle}); |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
var widgets = <Widget>[]; |
|
if (leftIcon != null || (leftImage != "")) { |
|
widgets.add( |
|
Padding( |
|
padding: EdgeInsets.only(left: 2.w), |
|
child: Icon( |
|
leftIcon, |
|
size: iconSize, |
|
color: iconColor, |
|
), |
|
), |
|
); |
|
} |
|
|
|
widgets.add(SizedBox( |
|
width: space, |
|
)); |
|
|
|
widgets.add(isMax |
|
? Expanded( |
|
child: Text( |
|
text, |
|
overflow: overFlow, |
|
// maxLines: 2, |
|
textAlign: TextAlign.start, |
|
style: textStyle, |
|
), |
|
flex: 1, |
|
) |
|
: Text( |
|
text, |
|
overflow: overFlow, |
|
textAlign: TextAlign.center, |
|
style: textStyle, |
|
)); |
|
|
|
widgets.add(SizedBox( |
|
width: space, |
|
)); |
|
|
|
if (rightIcon != null || rightImage != "") { |
|
widgets.add( |
|
Padding( |
|
padding: EdgeInsets.only(left: 2.w), |
|
child: Icon( |
|
rightIcon, |
|
size: iconSize, |
|
color: iconColor, |
|
), |
|
), |
|
); |
|
} |
|
return Container( |
|
child: Row( |
|
mainAxisAlignment: |
|
isMax ? MainAxisAlignment.center : MainAxisAlignment.start, |
|
crossAxisAlignment: textAxisAlignment, |
|
mainAxisSize: MainAxisSize.min, |
|
children: widgets, |
|
), |
|
); |
|
} |
|
}
|
|
|