将文字包裹在颤动中
wrap text in flutter
我想要带有位置图标的文本排在最后一行,当我的位置文本将被排序时,它应该排在该行的最后,当位置文本很长时,它应该换行并显示虚线,
我想要带有位置图标的文本排在最后一行,当我的位置文本将被排序时,它应该排在该行的最后,当位置文本很长时,它应该换行并显示虚线,
怎么做,
locationView() {
return Padding(
padding: const EdgeInsets.fromLTRB(16, 20, 16, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
bellazTitle("Hey, Emily", 22),
],
),
SizedBox(width: 10,),
Container(
// width: MediaQuery.of(context).size.width-160,
child: Row(
// mainAxisAlignment: MainAxisAlignment.end,
children: [
Image.asset(
"lib/Assets/location.png",
height: 22,
width: 16,
),
featureName == null
? Container()
: Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Column(
children: [
Container(
// color: Colors.red,
// width: MediaQuery.of(context).size.width-190,
child: Text(
// "${featureName}, ${locality}",
"as fhf sdfghj xchjk sdfghjk dfghjk zj ",
style: TextStyle(
color: apptitleColor,
fontSize: t4Size,
),maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
],
),
)
],
),
)
],
),
Padding(
padding: const EdgeInsets.only(top: 2.0),
child: Text(
"Welcome to Bellaz!",
style: TextStyle(
color: extraLightColor,
fontSize: t5Size,
),
),
)
],
),
);
}
您需要做的就是设置一个MAX_LOCATION_TXT_LEN,如果通过它则只显示第一个字符
static const MAX_LOCATION_TXT_LEN = 20;
String longTxt ="This text is too long";
String shortTxt = longTxt.length <= MAX_LOCATION_TXT_LEN ? longTxt : longTxt.substring(0, MAX_LOCATION_TXT_LEN) + "...";
尝试使用灵活或扩展的小部件来包裹您的文本。
我想要带有位置图标的文本排在最后一行,当我的位置文本将被排序时,它应该排在该行的最后,当位置文本很长时,它应该换行并显示虚线,
我想要带有位置图标的文本排在最后一行,当我的位置文本将被排序时,它应该排在该行的最后,当位置文本很长时,它应该换行并显示虚线,
怎么做,
locationView() {
return Padding(
padding: const EdgeInsets.fromLTRB(16, 20, 16, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
bellazTitle("Hey, Emily", 22),
],
),
SizedBox(width: 10,),
Container(
// width: MediaQuery.of(context).size.width-160,
child: Row(
// mainAxisAlignment: MainAxisAlignment.end,
children: [
Image.asset(
"lib/Assets/location.png",
height: 22,
width: 16,
),
featureName == null
? Container()
: Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Column(
children: [
Container(
// color: Colors.red,
// width: MediaQuery.of(context).size.width-190,
child: Text(
// "${featureName}, ${locality}",
"as fhf sdfghj xchjk sdfghjk dfghjk zj ",
style: TextStyle(
color: apptitleColor,
fontSize: t4Size,
),maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
],
),
)
],
),
)
],
),
Padding(
padding: const EdgeInsets.only(top: 2.0),
child: Text(
"Welcome to Bellaz!",
style: TextStyle(
color: extraLightColor,
fontSize: t5Size,
),
),
)
],
),
);
}
您需要做的就是设置一个MAX_LOCATION_TXT_LEN,如果通过它则只显示第一个字符
static const MAX_LOCATION_TXT_LEN = 20;
String longTxt ="This text is too long";
String shortTxt = longTxt.length <= MAX_LOCATION_TXT_LEN ? longTxt : longTxt.substring(0, MAX_LOCATION_TXT_LEN) + "...";
尝试使用灵活或扩展的小部件来包裹您的文本。