{"id":1935,"date":"2022-04-07T06:10:22","date_gmt":"2022-04-07T06:10:22","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=1935"},"modified":"2022-04-07T06:10:22","modified_gmt":"2022-04-07T06:10:22","slug":"variables-and-functions","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/04\/07\/variables-and-functions\/","title":{"rendered":"Variables and Functions"},"content":{"rendered":"\n<p>Variables are the namespace in memory that stores values. The name of a variable is called as&nbsp;<strong>identifiers<\/strong>. They are the data containers, which can store the value of any type. For example:<a href=\"https:\/\/www.javatpoint.com\/flutter-dart-programming#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/flutter-dart-programming#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/flutter-dart-programming#\"><\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var myAge = 50;  <\/code><\/pre>\n\n\n\n<p>Here,&nbsp;<strong>myAge<\/strong>&nbsp;is a variable that stores an integer value 50. We can also give it int and double. However, Dart has a feature Type Inference, which infers the types of values. So, if you create a variable with a&nbsp;<strong>var<\/strong>&nbsp;keyword, Dart can infer that variable as of type integer.<\/p>\n\n\n\n<p>Besides variable, Functions are another core feature of any programming language. Functions are a set of statements that performs a specific task. They are organized into the logical blocks of code that are readable, maintainable, and reusable. The function declaration contains the function name, return type, and parameters. The following example explains the function used in Dart programming.<a href=\"https:\/\/www.javatpoint.com\/flutter-dart-programming#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/flutter-dart-programming#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/flutter-dart-programming#\"><\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/Function declaration  \nnum addNumbers(num a, num b) {  \n    \/\/ Here, we use num as a type because it should work with int and double both.  \n    return a + b;  \n}  \nvar price1 = 29.99;  \nvar price2 = 20.81;  \nvar total = addNumbers(price1, price2);  \nvar num1 = 10;  \nvar num2 = 45;  \nvar total2 = addNumbers(num1, num2);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Variables are the namespace in memory that stores values. The name of a variable is called as&nbsp;identifiers. They are the data containers, which can store the value of any type. For example: Here,&nbsp;myAge&nbsp;is a variable that stores an integer value 50. We can also give it int and double. However, Dart has a feature Type [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[659],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1935"}],"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=1935"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1935\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=1935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=1935"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=1935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}