Я пытаюсь изменить состояние ExpansionTile, но мне не удалось выполнить эту задачу.
Вот часть моего кода, как вы можете видеть, у меня есть GestureDetector с функцией onTab который выполняет setState, и у меня есть ExpansionTile с initiallyExpanded
и onExpansionChanged
, но ничего не меняется ...
Как я могу изменить состояние ExpansionTile?
return Padding(
padding: EdgeInsets.only(
top: 8,
bottom: 4,
left: 16,
right: 16
),
child: Column(
children: <Widget>[
SizedBox(
height: 230,
child: GestureDetector(
onTap: () {
setState(() {
expanded = expanded ? false : true;
});
},
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0)
),
clipBehavior: Clip.antiAliasWithSaveLayer,
elevation: 4.0,
child: Stack(
fit: StackFit.expand,
children: [
image,
// imageOverlayGradient,
_buildTextContainer(context)
],
),
),
)
),
ExpansionTile(
initiallyExpanded: expanded,
onExpansionChanged: _onExpansionChanged,
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
widget.item.title,
style: TextStyle(
fontWeight: FontWeight.w700
),),
Text(
widget.item.subtitle,
style: TextStyle(
color: Colors.black
),)
],
),
children: <Widget>[
Container(
padding: EdgeInsets.symmetric(horizontal: 16.0),
child: Html(
data: widget.item.content,
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 16.0),
child: ButtonBar(
// mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
FlatButton(
onPressed: () => _launchURL(_buildWhatsappUrl().toString()),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50.0)
),
color: Colors.green,
textColor: Colors.white,
child: Text("Whatsapp"),
),
FlatButton(
onPressed: () => _launchURL("tel:${widget.item.phone}"),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50.0)
),
color: Colors.amber,
textColor: Colors.white,
child: Text("Llamar"),
),
],
),
),
],
)
],
),
);