How to implement call back function in Dart

MIB Coder
Oct 19, 2019

--

What you are going to learn: How to implement a call-back function to get back data from the delegate class in three steps.

To read the latest version of this article click here: https://mibcoder.com

call back function in dart

Step: 1- Take function as a parameter

void downloadProgress({Function(int) callback}) {............................}

Step: 2- Set data to function, the data which have to send back from the delegate class

if(callback!=null)callback(progress);

Step: 3- Pass function in parameters from calling class.

dataProcessor.downloadProgress(callback: (int progress) {
print('download progress : $progress');
});

Here is the complete code:

Download complete source code from Github:

link

https://github.com/codinghivedev/callback_function_in_dart

Thanks for reading, if you like please follow me.

--

--