我需要脱开FlatButton并使用按钮功能的onPressed将这个功能放到所有容器中。我不知道是否有可能...我该怎么做?
Widget _buildFrontWidget() {
return Container(
color: Colors.white,
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("CARD",
style: TextStyle(
color: Color(0xFF2e282a),
fontSize: 20.0,
fontWeight: FontWeight.w800)
),
FlatButton(
onPressed: () => _foldingCellKey?.currentState?.toggleFold(),
child: Text(
"Open",
),
textColor: Colors.white,
color: Colors.indigoAccent,
splashColor: Colors.white.withOpacity(0.5),
)
],
));
}
Widget _buildInnerTopWidget() {
return Container(
color: Color(0xFFff9234),
alignment: Alignment.center,
child: Text("TITLE",
style: TextStyle(
color: Color(0xFF2e282a),
fontFamily: 'OpenSans',
fontSize: 20.0,
fontWeight: FontWeight.w800)));
}
Widget _buildInnerBottomWidget() {
return Container(
color: Color(0xFFecf2f9),
alignment: Alignment.bottomCenter,
child: Padding(
padding: EdgeInsets.only(bottom: 10),
child: FlatButton(
onPressed: () => _foldingCellKey?.currentState?.toggleFold(),
child: Text(
"Close",
),
textColor: Colors.white,
color: Colors.indigoAccent,
splashColor: Colors.white.withOpacity(0.5),
),
),
);
}
答案 0 :(得分:0)
像这样包裹在InkWell中
Widget _buildFrontWidget() {
return InkWell(
onTap: _foldingCellKey?.currentState?.toggleFold(),
child: Container(
color: Colors.white,
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("CARD",
style: TextStyle(
color: Color(0xFF2e282a),
fontSize: 20.0,
fontWeight: FontWeight.w800)),
],
)),
);
}