I've got an AnimatedContainer which is able to change its height by an Inkwell with onTap. The reason is that the Container should show all TextSpans of RichText. My problem is that I have no idea how to get the height of the onTap flexible. If I add more TextSpans I have to edit the height in the Inkwell to set a new height. I want the Container to show ALL 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'),
],
),
);
User contributions licensed under CC BY-SA 3.0