[英]Flutter - Font Awesome Icon overflow with Text
I'm using FontAwesomeIcon Plugin in my application.我在我的应用程序中使用FontAwesomeIcon 插件。
Some Icons from FontAwesomeIcon plugin are overlap with Text widget like below Image. FontAwesomeIcon 插件中的一些图标与文本小部件重叠,如下图所示。
I can solve this problem by adding some width between Text and Icon, but that is not good.我可以通过在 Text 和 Icon 之间添加一些宽度来解决这个问题,但这并不好。 so how to solve this problem.
那么如何解决这个问题。
I need like this Image.我需要这样的图像。
here i'm not adding any width between icon and text.这里我没有在图标和文本之间添加任何宽度。
Code:代码:
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: <Widget>[
Icon(
Icons.trip_origin,
color: Colors.white,
),
Text(
'TP-23',
style: TextStyle(color: Colors.white),
)
],
),
Row(
children: <Widget>[
Icon(
FontAwesomeIcons.idCard,
color: Colors.white,
),
Text(
'TP-23',
style: TextStyle(color: Colors.white),
)
],
)
],
),
Are you looking like this ?你看起来像这样吗?
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: <Widget>[
Icon(
Icons.trip_origin,
color: Colors.white,
),
SizeBox(width:10) //as per your requirement
Text(
'TP-23',
style: TextStyle(color: Colors.white),
)
],
),
Row(
children: <Widget>[
Icon(
FontAwesomeIcons.idCard,
color: Colors.white,
),
SizeBox(width:10) //as per your requirement
Text(
'TP-23',
style: TextStyle(color: Colors.white),
)
],
)
],
),
Why don't you just use the Padding widget ( https://api.flutter.dev/flutter/widgets/Padding-class.html ) like this为什么不像这样使用 Padding 小部件( https://api.flutter.dev/flutter/widgets/Padding-class.html )
ADD PADDING TO THE LEFT AND RIGHT TO THE ICON WIDGET在图标小部件的左侧和右侧添加填充
Row(
children: <Widget>[
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0)
child: Icon(
Icons.trip_origin,
color: Colors.white,
),
),
Text(
'TP-23',
style: TextStyle(color: Colors.white),
)
]
)
ADD PADDING ONLY TO THE RIGHT TO THE ICON WIDGET仅在图标小部件的右侧添加填充
Row(
children: <Widget>[
Padding(
padding: EdgeInsets.only(right: 16.0)
child: Icon(
Icons.trip_origin,
color: Colors.white,
),
),
Text(
'TP-23',
style: TextStyle(color: Colors.white),
)
]
)
child: Container(
child: Container(
height: 500.0,
width: 500.0,
// alignment: FractionalOffset.center,
child: Stack(
//alignment:new Alignment(x, y)
children: <Widget>[
Icon(
Icons.trip_origin,
size: 40.0,
color: Colors.orange,
),
Positioned(
top: 15.00,
left: 40.0,
child: Text(
'TP-23',
style: TextStyle(
color: Colors.white, fontSize: 25.0),
),
)
],
),
),
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.