DEV Community

Cover image for Higher Order Functions
Anin Arafath
Anin Arafath

Posted on

4 2

Higher Order Functions

What Is Higher order function?
In dart programming language can accept a function as an argument, this type of functions is called higher order functions.

for example :-

void printUser(String Function() getUser)
{
    // getting user maybe it's from api like etc.
    String user = getUser();

   // and print the user.
    print(user);
  }
Enter fullscreen mode Exit fullscreen mode

Here the PrintUser is a higher order function because printUser function is accept a function named getUser as an argument, that void printUser(String Function() getUser){ }.

The functions are first class citizens in dart programming language because, They can be assigned to a variable, passed as an argument to another function, returned from a function, stored in other Data collections, and created in any scope.

What is callback function?


// this function called higher order function.
void higherOrderFunction(String Function() callbackFunction)
{

  // this function called callback function generally.
  callbackFunction();

 }
Enter fullscreen mode Exit fullscreen mode

A function passed as the argument of another function , this kind of function is called callback functions and which function is accepted the callback function that function is called higher order function.

Sentry mobile image

Improving mobile performance, from slow screens to app start time

Based on our experience working with thousands of mobile developer teams, we developed a mobile monitoring maturity curve.

Read more

Top comments (1)

Collapse
 
nalbiy profile image
Nalbiy

How about if function recieve defferent callback functions with defferent arguments?

Sentry growth stunted Image

If you are wasting time trying to track down the cause of a crash, it’s time for a better solution. Get your crash rates to zero (or close to zero as possible) with less time and effort.

Try Sentry for more visibility into crashes, better workflow tools, and customizable alerts and reporting.

Switch Tools

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay