且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Flutter-将函数传递给StatelessWidget不起作用

更新时间:2023-11-12 09:55:16

由于您没有将其直接绑定到onPressed事件,因此需要调用该函数.试试这个:

Since you are not binding it directly to the onPressed event, you need to call the function. Try this:

    new FlatButton(
      onPressed: () {
        btnSi == null ? Navigator.of(context).pop(true):btnSi();
      },
      child: new Text("Si"),
    )