How to Write Inline Arrow Functions in Dart Flutter With Example

An Inline function supports one line short syntax expression. Inline functions mostly used to perform single task. The way they execute will make them faster on any platform. So in today’s tutorial we would learn about How to Write Inline Arrow Functions in Dart Flutter With Example in Android iOS App. We would use the Arrow function with combination of Inline functions here.

Syntax:

Contents in this project How to Write Inline Arrow Functions in Dart Flutter With Example:

1. Open your project’s main.dart file and import material.dart package.

2. Create void main runApp() method and here we would call our main MyApp class.

3. Creating our main class named as MyApp extends State less widget. This is our main View class.

4. Creating Inline Arrow function named as myName. The method is String return type. We would call this method in Text widget and pass a Text inside it. It will print the argument Text on screen.

5. Creating Widget Build Area -> Material App Widget -> Scaffold Widget -> Center Widget -> Column Widget -> Text widget.

  • Here we would call the myName() method with some random text and print the Text on Screen with function return message.

6. Complete source code for main.dart file:

Screenshot:

How to Write Inline Arrow Functions in Dart Flutter With Example

Leave a Reply

Your email address will not be published.