0

如果我没有通过函数而只是用 print 进行测试,它就可以工作。我在小部件上传递了 3 个函数,点击的 CircleAvatar 可以工作,但不能使用 RawMaterial / 按钮

       RawMaterialButton(
        onPressed: () => bannerTap,//print('raw'),
        child: RichText(
          text: TextSpan(
            //recognizer: TapGestureRecognizer()..onTap  = ()=> print('Text tapped'),
            text: info,
            style: TextStyle(color: Colors.white),
            children: <TextSpan>[
              TextSpan(text: actionMessage, style: TextStyle(fontWeight: FontWeight.bold)),
            ],
          ),

        ),
      ),
4

2 回答 2

0

错字,只需要确保自定义小部件不包含(){}函数名,并且只传递属性

于 2021-03-04T17:49:51.113 回答
0

您需要调用函数而不是函数名。

onPressed: () => bannerTap()
于 2021-02-25T01:55:02.467 回答