{"id":3614,"date":"2022-05-21T06:26:54","date_gmt":"2022-05-21T06:26:54","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=3614"},"modified":"2022-05-21T06:26:54","modified_gmt":"2022-05-21T06:26:54","slug":"the-main-function","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/05\/21\/the-main-function\/","title":{"rendered":"The main() function"},"content":{"rendered":"\n<p>The main() function is the top-level function of the Dart. It is the most important and vital function of the\u00a0Dart\u00a0programming language. The execution of the programming starts with the\u00a0<strong>main()<\/strong>\u00a0function. The\u00a0<strong>main()<\/strong>\u00a0function can be used only once in a program.<\/p>\n\n\n\n<p>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&lt;String&gt; parameter as arguments. The general syntax of the main() function is given below.<\/p>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/www.javatpoint.com\/dart-main-function#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-main-function#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-main-function#\"><\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void main() {  \n  \/\/ main function body  \n}  <\/code><\/pre>\n\n\n\n<p><strong>Example &#8211; 1<\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/www.javatpoint.com\/dart-main-function#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-main-function#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-main-function#\"><\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void main()   \n{  \n  print(\"Welcome To Javapoint\");  \n    \n }  <\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Welcome To Javapoint\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Dart Return Value<\/h2>\n\n\n\n<p>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&nbsp;<strong>return<\/strong>&nbsp;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.<\/p>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/www.javatpoint.com\/dart-main-function#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-main-function#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-main-function#\"><\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>return &lt;expression\/value>;  <\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Dart value with Return Value<\/h2>\n\n\n\n<p>Below is given syntax of return value.<\/p>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/www.javatpoint.com\/dart-main-function#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-main-function#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-main-function#\"><\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>return_type function_name()   \n{  \n   \/\/statement(s);  \n  return value;  \n}  <\/code><\/pre>\n\n\n\n<p>Here is the description of the above syntax.<\/p>\n\n\n\n<p><strong>function_name &#8211;<\/strong>&nbsp;It represents the function name, which can be any valid identifier.<\/p>\n\n\n\n<p>return type &#8211; 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.<\/p>\n\n\n\n<p>Let&#8217;s understand the following example &#8211;<\/p>\n\n\n\n<p><strong>Example &#8211;<\/strong><a href=\"https:\/\/www.javatpoint.com\/dart-main-function#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-main-function#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/dart-main-function#\"><\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void main() {  \n  int mul(int a, int b){  \n        int c = a*b;  \n        return c;  \n}  \nprint(\"The multiplication of two numbers: ${mul(10,20)}\");  \n}  <\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The multiplication of two numbers: 200<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The main() function is the top-level function of the Dart. It is the most important and vital function of the\u00a0Dart\u00a0programming language. The execution of the programming starts with the\u00a0main()\u00a0function. The\u00a0main()\u00a0function 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[918],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/3614"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=3614"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/3614\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=3614"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=3614"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=3614"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}