У меня есть AnimatedContainer, и как его дочерний элемент, у меня есть строка, содержащая текст и IconButton. После нажатия какой-либо кнопки я переключаю высоту контейнера между 0 и 100. Когда высота контейнера равна нулю, IconButton все еще виден (не текст) и не доступен для нажатия.
Widget _myAnimatedContainer() {
return AnimatedContainer(
curve: Curves.easeOut,
alignment: Alignment.center,
duration: Duration(milliseconds: 300),
height: height,
color: Colors.green,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Text(
'Animated Container',
style: TextStyle(fontSize: 20),
overflow: TextOverflow.ellipsis,
),
IconButton(icon: Icon(Icons.favorite_border), onPressed: () {},)
],
),
);
}
class _AnimatedContainerExampleState extends State<AnimatedContainerExample> {
double height = 100;
bool isExpanded = false;
@override
Widget build(BuildContext context) {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
_myAnimatedContainer(),
SizedBox(height: 20,),
RaisedButton(
child: Text('Expand'),
onPressed: () {
setState(() {
isExpanded = !isExpanded;
height = isExpanded ? 100 : 0;
});
},
),
],
),
);
}
Пожалуйста, предложите, как решить эту проблему.