我有一个AnimatedContainer,它可以使用onTap通过Inkwell更改其高度。原因是容器应显示RichText的所有TextSpans。我的问题是我不知道如何获得onTap flexible的高度。如果添加更多TextSpans,则必须在Inkwell中编辑高度以设置新高度。我希望容器显示所有TextSpans。
class NotificationAnimated extends StatefulWidget {
@override
_NotificationAnimatedState createState() => _NotificationAnimatedState();
}
class _NotificationAnimatedState extends State<NotificationAnimated> {
double customHeight = 72;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
setState(() {
if (customHeight == 72) {
customHeight = 169;
historyRed(customHeight);
} else
customHeight = 72;
});
},
child: AnimatedContainer(
duration: Duration(milliseconds: 250),
width: 323,
height: customHeight,
margin: EdgeInsets.only(bottom: 10),
color: Color(0xff2e2e2e),
child: Row(
children: <Widget>[
historyRed(customHeight),
Container(
width: 43,
height: 23,
margin:
EdgeInsets.only(left: 20, top: 13, bottom: customHeight - 36),
child: Text(
'$time',
style: TextStyle(
fontSize: 18,
fontFamily: "AssistantLight",
color: Color(0xffffffff),
),
),
),
ConstrainedBox(
constraints: BoxConstraints(minHeight: 46),
child: Container(
width: 240,
margin: EdgeInsets.only(left: 15, bottom: 13, top: 13),
height: customHeight,
child: text,
),
),
],
),
),
);
}
}
var text = RichText(
text: TextSpan(
style: TextStyle(
fontSize: 18.0,
fontFamily: "AssistantLight",
color: Color(0xffffffff),
),
children: <TextSpan>[
TextSpan(
text: 'Max Mustermann\nLOCKDOWN\n',
style: TextStyle(fontFamily: "AssistantSemiBold"),
),
TextSpan(text: 'Bürotür\n'),
TextSpan(text: 'Zwischentür\n'),
TextSpan(text: 'Haustür\n'),
TextSpan(text: 'Garagentür'),
],
),
);