0

I'm confused with arrow syntax in this Navigator implementation:

Navigator.push(
   MaterialPageRoute(
      context,
      builder: (context) => aWidgetConstructor()
   )
)

From what I guess, the 4th line is similar to

Widget build(Buildcontext context){
   return aWidgetConstructor(
   ...
   )
}

So how can one explain this syntax work, and why function expression can't be named?

Thanks.

  • Does this answer your question? [What's the meaning of “=>” (arrow) in Dart/Flutter?](https://stackoverflow.com/questions/65343818/whats-the-meaning-of-arrow-in-dart-flutter) – MendelG Jun 28 '21 at 22:54

1 Answers1

0

This question is simple. This is the syntax of the language. Arrow Functions or Anonymous Functions are functions that have not names. This is the result of the popularity of functional languages using this type of technology that simplifies and minimizes the length of the code. This is simple and powerful.

On other hand, inheritance is the result of the OOP languages that show the importance of interfaces and contracts to standardize and generalize the usage of extern code. This was popularized with java and the programming community approves overall.

The operation of both solutions can be easily explained with function pointers. The more difficult to explain is the inheritance of the context of Arrow Functions. Someone that knows about C++ can explain better, but you can imagine an Arrow Function is only another class that captures all the outer values to self and do your task with these references.