Flutter 文本溢出时如何淡入淡出?
我在处理溢出的文本时遇到问题。我尝试了Flutter 文本溢出时如何淡入淡出?,flutter,Flutter,我在处理溢出的文本时遇到问题。我尝试了溢出:textfloverf.xxxx,扩展的和灵活的,但仍然不起作用。有人能帮我解决这个问题吗 class _FeaturedCardState extends State<FeaturedCard>{ @override Widget build(BuildContext context) { return InkWell( onTap: () { showToast(widget.na
溢出:textfloverf.xxxx
,扩展的和灵活的,但仍然不起作用。有人能帮我解决这个问题吗
class _FeaturedCardState extends State<FeaturedCard>{
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
showToast(widget.name, context);
},
child: Padding(
padding: EdgeInsets.only(top: 5.0),
child: Container(
height: MediaQuery.of(context).size.height / 9,
width: MediaQuery.of(context).size.width,
child: Card(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
elevation: 3.0,
child: Row(
children: <Widget>[
Padding(
padding: EdgeInsets.all(5.0),
child: CircleAvatar(
radius: 20,
backgroundImage: AssetImage(widget.img),
backgroundColor: Colors.transparent,
),
),
SizedBox(width: 10),
Padding(
padding: EdgeInsets.fromLTRB(0.0, 3.0, 3.0, 3.0),
child: Wrap(
direction: Axis.vertical,
children: <Widget>[
SizedBox(height: 2),
Text(
widget.name,
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 15,
color: Colors.blueGrey,
),
),
SizedBox(height: 3),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Icon(
Icons.attach_money,
size: 11,
),
Text(
widget.salary,
style: TextStyle(
fontSize: 10,
fontFamily: 'Montserrat',
color: Colors.blue[300]
),
)
],
),
SizedBox(height: 3),
Text( // This is the text that overflows
widget.desc,
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 12,
),
maxLines: 1,
softWrap: false,
overflow: TextOverflow.fade,
),
],
),
)
],
),
),
),
),
);
}
类_FeaturedCardState扩展状态{
@凌驾
小部件构建(构建上下文){
回墨槽(
onTap:(){
showToast(widget.name,context);
},
孩子:填充(
填充:仅限边缘设置(顶部:5.0),
子:容器(
高度:MediaQuery.of(context).size.height/9,
宽度:MediaQuery.of(context).size.width,
孩子:卡片(
形状:RoundedRectangleBorder(borderRadius:borderRadius.circular(5.0)),
标高:3.0,
孩子:排(
儿童:[
填充(
填充:所有边缘设置(5.0),
孩子:圆环星(
半径:20,
背景图片:AssetImage(widget.img),
背景颜色:颜色。透明,
),
),
尺寸箱(宽度:10),
填充物(
填充:来自LTRB(0.0,3.0,3.0,3.0)的边缘设置,
孩子:包裹(
方向:轴垂直,
儿童:[
尺寸箱(高度:2),
文本(
widget.name,
样式:TextStyle(
fontFamily:“蒙特塞拉特”,
尺寸:15,
颜色:颜色。蓝灰色,
),
),
尺寸箱(高度:3),
划船(
mainAxisAlignment:mainAxisAlignment.start,
儿童:[
图标(
图标。附上钱,
尺码:11,
),
正文(
1.薪水,
样式:TextStyle(
尺寸:10,
fontFamily:“蒙特塞拉特”,
颜色:颜色。蓝色[300]
),
)
],
),
尺寸箱(高度:3),
Text(//这是溢出的文本
widget.desc,
样式:TextStyle(
fontFamily:“蒙特塞拉特”,
尺寸:12,
),
maxLines:1,
软包装:错误,
溢出:TextOverflow.fade,
),
],
),
)
],
),
),
),
),
);
}
我已经搜索了很多atricles,但仍然没有任何帮助。如果有人能想出一个解决方案,那将是非常棒的。任何帮助都将不胜感激,谢谢。你可以试试这个
class _FeaturedCardState extends State<FeaturedCard> {
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.all(5.0),
child: Material(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
),
elevation: 3.0,
child: InkWell(
borderRadius: BorderRadius.circular(5.0),
onTap: (){
showToast(widget.name, context);
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: <Widget>[
CircleAvatar(
radius: 20,
backgroundImage: AssetImage(widget.img),
backgroundColor: Colors.transparent,
),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text(
widget.name,
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 15,
color: Colors.blueGrey,
),
),
const SizedBox(height: 3),
Text(
"\u0024${widget.salary}", // Char code for $ symbol "\u0024"
style: TextStyle(
fontSize: 10,
fontFamily: 'Montserrat',
color: Colors.blue[300],
),
),
const SizedBox(height: 3),
Text(
// This is the text that overflows
widget.desc,
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 12,
),
maxLines: 1,
softWrap: false,
overflow: TextOverflow.fade,
),
],
),
)
],
),
),
),
),
);
}
}
class\u功能CardState扩展状态{
@凌驾
小部件构建(构建上下文){
返回填充(
填充:所有边缘设置(5.0),
儿童:材料(
形状:圆形矩形边框(
边界半径:边界半径。圆形(5.0),
),
标高:3.0,
孩子:InkWell(
边界半径:边界半径。圆形(5.0),
onTap:(){
showToast(widget.name,context);
},
孩子:填充(
填充:常数边集全部(8.0),
孩子:排(
儿童:[
圆形(
半径:20,
背景图片:AssetImage(widget.img),
背景颜色:颜色。透明,
),
常量大小框(宽度:10),
扩大(
子:列(
crossAxisAlignment:crossAxisAlignment.stretch,
儿童:[
正文(
widget.name,
样式:TextStyle(
fontFamily:“蒙特塞拉特”,
尺寸:15,
颜色:颜色。蓝灰色,
),
),
const SizedBox(高度:3),
正文(
“\u0024${widget.salary},//字符代码为$symbol”\u0024”
样式:TextStyle(
尺寸:10,
fontFamily:“蒙特塞拉特”,
颜色:颜色。蓝色[300],
),
),
const SizedBox(高度:3),
正文(
//这是溢出的文本
widget.desc,
样式:TextStyle(
fontFamily:“蒙特塞拉特”,
尺寸:12,
),
maxLines:1,
软包装:错误,
溢出:TextOverflow.fade,
),
],
),
)
],
),
),
),
),
);
}
}
您可以试试这个
class _FeaturedCardState extends State<FeaturedCard> {
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.all(5.0),
child: Material(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
),
elevation: 3.0,
child: InkWell(
borderRadius: BorderRadius.circular(5.0),
onTap: (){
showToast(widget.name, context);
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: <Widget>[
CircleAvatar(
radius: 20,
backgroundImage: AssetImage(widget.img),
backgroundColor: Colors.transparent,
),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text(
widget.name,
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 15,
color: Colors.blueGrey,
),
),
const SizedBox(height: 3),
Text(
"\u0024${widget.salary}", // Char code for $ symbol "\u0024"
style: TextStyle(
fontSize: 10,
fontFamily: 'Montserrat',
color: Colors.blue[300],
),
),
const SizedBox(height: 3),
Text(
// This is the text that overflows
widget.desc,
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 12,
),
maxLines: 1,
softWrap: false,
overflow: TextOverflow.fade,
),
],
),
)
],
),
),
),
),
);
}
}
class\u功能CardState扩展状态{
@凌驾
小部件构建(构建上下文){
返回填充(
填充:所有边缘设置(5.0),
儿童:材料(
形状:圆形矩形边框(
边界半径:边界半径。圆形(5.0),
),
标高:3.0,
孩子:InkWell(
边界半径:边界半径。圆形(5.0),
在…上