I tend to ask this question because most of the time we directly call the runApp function main and do nothing else. My question is that why was runApp and main kept different? It could have been simple that either main function or runApp function was kept and other was discarded?
The runApp() function takes the given Widget and makes it the root of the widget tree. In this example, the widget tree consists of two widgets, the Center widget and its child, the Text widget. The framework forces the root widget to cover the screen, which means the text “Hello, world” ends up centered on screen.
2->runApp()--=>this is the main function that runs the main screen. With help of this widget, you can run those screens that you want to run. This screen is known as the root screen of your app.
Runapp is one of many adware-type apps that form part of the Pirrit adware family. Typically, apps of this type feed users with unwanted ads, however, they might also gather user details. Research shows that Runapp installs another identical app called MacPerformance (also part of Pirrit adware).
The main() function is a predefined method in Dart. This method acts as the entry point to the application. A Dart script needs the main() method for execution. print() is a predefined function that prints the specified string or value to the standard output i.e. the terminal.
In Dart, main() acts as the entry point for the program whereas runApp() attaches the given widget to the screen.
According to this post, it's possible to establish configuration variables before actually attaching the first widget. This makes the separation between main() and runApp() pretty useful. For example, you can update all of the following before attaching the first widget:
main ()
function came from Java-like languages so it's where all program started, without it, you can't write any program on Flutter even without UI.
And runApp()
function should return Widget that would be attached to the screen as a root of the Widget Tree that will be rendered.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With