Darts: Converting Fat Arrow Syntax into elaborate syntax

The fat arrow is a short hand for creating a new symbol.

Many articles talks about how to convert declaration of function into fat arrows.  But not vice-versa.
Lets talk about an example in Google Codelabs and show the 2 simple steps to do so.

Original Code
Navigator.push(context, MaterialPageRoute(builder: (context) => DetailScreen(dtodo: todos[index]),),);


1a. Replace fat arrow by {

Navigator.push(context, MaterialPageRoute(builder: (context) =>  { DetailScreen(dtodo: todos[index]),),);


1b. Isolate the another end of the function and close it with }

Navigator.push(context, MaterialPageRoute(builder: (context) =>  { DetailScreen(dtodo: todos[index]),}
),
);


2.Add Return and replace the , by ;

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

 return DetailScreen(dtodo: todos[index]),;}
),
);

Navigator.push(context, MaterialPageRoute(builder: (context)
    {
    return DetailScreen(dtodo: todos[index]);}//DetailScreen
),//MaterialPageRoute);//Navigator 
For more on how to use Fat Arrow see video

Comments

Popular posts from this blog

Flutter Widget 101 Part 1 (Basic of Flutters, Layouts, Rows and Columns)

Setting up Terminal in Android Studio for Flutter and Bash Profile (For Mac)

Flutter Widget 101 Part 5 (Snackbars, Context, Builder and Key)