Callback in flutter with example

Satheesh Guduri
2 min readDec 8, 2020

--

Hello everyone, In this article i am gonna show you callback funtionality in flutter by using the counter app/sample app.

I wanna make it simple and short, So, i am dividing in to two parts.

First Part:

Here, we are adding callBackMethod and to MyHomePage

In this class when user clicking on float button _incrementCounter will be invokes.

and we are calling widget.callBackMethod() after onpress on button.

Second Step:

finally, when we using MyHomePage( ), here the callback will invoked. It means when user clicking on floating button then the print method will invoke.

And if you want to send any data to call back then you can write the code like below

final Function(String) responce;widget.responce(name);

If you found this article helpful click and hold 👏 a button and show some love and help others to find this article.

Feeling more generous, you can buy me a cup of tea.

--

--

Satheesh Guduri
Satheesh Guduri

Written by Satheesh Guduri

Mobile App Developer and Trainer

No responses yet