一切正常,但是popupmenubutton
直到选择了任何弹出项都不会关闭。
我不明白为什么不叫onCanceled
。
请帮助我。
我提供了以下源代码。 谢谢。
//从这里打电话
StatefulWidget> CustomScrollView{
child: callAction(
tooltip: "Call Button",
child: Container(
height: double.infinity,
padding: EdgeInsets.all(20),
child: Icon(Icons.call)
),
),
}
// PopupMenuButton小部件
enum CallActionType { DataCall, Sim1Call, Sim2Call}
class callAction extends StatelessWidget {
Widget child;
String tooltip;
callAction({@required this.child, @required this.tooltip});
PopupMenuButton<CallActionType>(
elevation: 8,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0)),
onSelected: (CallActionType value) {
setState(() {
print(value);
});
},
//onCanceled didn't call
onCanceled: () {
print('You have not chossed anything');
},
tooltip: widget.tooltip,
offset: Offset(0, 100),
child: widget.child,
itemBuilder: (BuildContext context) => <PopupMenuEntry<CallActionType>>[
new PopupMenuItem<CallActionType>(
value: "Action 1",
child: Text('Action 1'),
),
new PopupMenuItem<CallActionType>(
value: "Action 2",
child: Text('Action 2'),
),
new PopupMenuItem<CallActionType>(
value: "Action 3",
child: Text('Action 3'),
),
],
);