Home » Dart main() function

Dart main() function

by Online Tutorials Library

The main() function

The main() function is the top-level function of the Dart. It is the most important and vital function of the Dart programming language. The execution of the programming starts with the main() function. The main() function can be used only once in a program.

It is responsible for all types of execution such as user-defined statements, functions, and libraries function. The program begins with main() function and we declares variable, and user defined executable statements inside it. The main function returns void and can have an optional List<String> parameter as arguments. The general syntax of the main() function is given below.

Syntax:

Example – 1

Output

Welcome to Tutor Aspire  

Dart Return Value

Sometimes the function returns a value after evaluating the function statements to the point where it is called from. The return statement holds the result of the function, and it is transferred to the function call. The return keyword is used to represent the return statement. If the return statement not specified, then the function returns null. The return statement is optional to specify in function, but there can be only one return statement in a function.

Syntax:

Dart value with Return Value

Below is given syntax of return value.

Syntax:

Here is the description of the above syntax.

function_name – It represents the function name, which can be any valid identifier.

return type – It denotes the return type of the function. It can be any valid data type. The return must be matched with the return type of the function.

Let’s understand the following example –

Example –

Output

The multiplication of two numbers: 200  

Next TopicDart Recursion

You may also like