Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do we execute two function in single button pressed in flutter

RaisedButton(
               color: Colors.blueAccent, 
               onPressed: () =>sendData(); //fun1
               signupPage(context) //fun2
               child: 
                Text("Signup"),
             )

this code gives an error..Expected to find ')'

enter image description here

like image 884
Space Avatar asked Jan 07 '19 05:01

Space


1 Answers

Arrow Function can run single statement function.

Options:

1 - You can run two Functions as Below.

RaisedButton(
               color: Colors.blueAccent, 
               onPressed: () {
               sendData(); //fun1
               signupPage(context); //fun2
               },
               child: 
                Text("Signup"),
             )

Or

2 - You can run fun2 in fun 1.

RaisedButton(
               color: Colors.blueAccent, 
               onPressed: () => sendData(context), //fun1
               child: 
                Text("Signup"),
             )

void sendData(BuildContext context){
//sendData Code ...
signupPage(context); //fun2
...
}
like image 64
anmol.majhail Avatar answered Oct 08 '22 16:10

anmol.majhail