Thursday, March 28, 2024

Main Entry point of a Flutter

All flutter apps must have a top level entry point main() function.
The main function refers to where the app start execution and main function return nothing that is return type of main function is void.
Most of the all main function has empty parameter with optional List.

We can use main function in 3 different ways.

1.using arrow syntax.
2.main function
3.List of string parameters

1.Using Arrow syntax

void main() => runApp(MyApp());

2.main function

void main() {
runApp(MyApp());
}

3.List of string parameters

void main(List list) {
print('datas- $list');
}

All the 3 ways to using main function are acceptable.
but using arrow expressions are most acceptable one because it keeps code on one line
for better readability .