在 ElevatedButton 中的 OnPress 时如何调用多个反应/动作

问题描述

我尝试在按下登录按钮时运行 2 个函数,但不起作用

我使用 MobX,这是我的代码

Observer(builder: (_) {
                          return ElevatedButton(
                            onpressed:
                                dadoslogin.apertouLogin as void Function()?,child: dadoslogin.carregando
                                ? SizedBox(
                                    height: altura / 40,width: largura / 20,child: CircularProgressIndicator(
                                      strokeWidth: largura / 200,valueColor: AlwaysstoppedAnimation(
                                        Color(0xFFFFFFFF),),)
                                : Text(
                                    "LOGIN",style: TextStyle(),);

使用此代码,我只运行:

@computed
  Function? get apertouLogin =>
      (loginoK && !carregando && senhaOK) ? logando : null;

但是,我需要这个

 @computed
  Function? get puxandoLogin => (!carregando) ? puxando : null;

这个:

onpressed: () {
  functionOne as void Function();
  functionTwo as void Function();
}

不工作

解决方法

onPressed: () {
  functionOne as void Function();
  functionTwo as void Function();
}