<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Raphael Kihiro</title>
    <description>The latest articles on DEV Community by Raphael Kihiro (@kihiro).</description>
    <link>https://dev.to/kihiro</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3548368%2F906f97ee-f497-4565-aee1-1c1536c8d202.png</url>
      <title>DEV Community: Raphael Kihiro</title>
      <link>https://dev.to/kihiro</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kihiro"/>
    <language>en</language>
    <item>
      <title>Functions in dart</title>
      <dc:creator>Raphael Kihiro</dc:creator>
      <pubDate>Mon, 10 Nov 2025 07:03:01 +0000</pubDate>
      <link>https://dev.to/kihiro/functions-in-dart-1njc</link>
      <guid>https://dev.to/kihiro/functions-in-dart-1njc</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;1. Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Functions are a fundamental construct in programming languages, enabling, code reusability, and improved maintainability. This in this segment I  will dive into the definition, structure, and invocation of functions in Dart, highlighting their syntax and purpose within program design.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.1 Function Definition.&lt;/strong&gt;&lt;br&gt;
A function in Dart is defined as a reusable block of code designed to execute a specific operation. The general syntax of a function is as follows:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F24fuussdntknf0kbez55.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F24fuussdntknf0kbez55.png" alt=" " width="800" height="71"&gt;&lt;/a&gt;&lt;br&gt;
In this example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;greet&lt;/code&gt; denotes the function name, which serves as the identifier for invocation.&lt;/li&gt;
&lt;li&gt;The parentheses&lt;code&gt;()&lt;/code&gt; may contain parameters, &lt;/li&gt;
&lt;li&gt;The curly braces &lt;code&gt;{}&lt;/code&gt; enclose the function body,&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a function to be executed it has to be invoked(called);&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1exusf877jfuz8xxg52o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1exusf877jfuz8xxg52o.png" alt=" " width="800" height="45"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To execute the Dart file, run the command&lt;code&gt;dart run&lt;/code&gt;(&lt;strong&gt;&lt;em&gt;file name&lt;/em&gt;&lt;/strong&gt;), in the terminal:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftxhtxfm6jp2fwkm4pl9m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftxhtxfm6jp2fwkm4pl9m.png" alt=" " width="800" height="25"&gt;&lt;/a&gt;&lt;br&gt;
When executed, this program prints:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvd9zq79pyzml8lelvkld.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvd9zq79pyzml8lelvkld.png" alt=" " width="262" height="34"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;2. Structure of a Function&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;2.1 The main() Function in Dart&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Dart, every standalone program must have a main() function, that serves as the entry point of the program. Without this function, Dart cannot determine where to start execution, leading to a runtime error.&lt;/p&gt;

&lt;p&gt;When you attempt to run a Dart program without defining a main() function, the following error appears:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq8daib89zlktnkkdtzek.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq8daib89zlktnkkdtzek.png" alt=" " width="800" height="55"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.1.1 Syntax of the main() Function&lt;/strong&gt;&lt;br&gt;
The &lt;code&gt;main()&lt;/code&gt; function has a simple and well-defined syntax. It’s also important to note that the&lt;code&gt;main()&lt;/code&gt;function returns &lt;code&gt;void&lt;/code&gt;, meaning it does not have a return value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvi2bwvrhzo1znln6emnj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvi2bwvrhzo1znln6emnj.png" alt=" " width="800" height="59"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.1.2  Example of the main() Function Calling Another Function&lt;/strong&gt;&lt;br&gt;
Here is an example demonstrating on how the &lt;code&gt;main()&lt;/code&gt; function interacts with other functions:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh661oy7ddduqb06m6orm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh661oy7ddduqb06m6orm.png" alt=" " width="800" height="142"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;greet()&lt;/code&gt; function is defined to return a string value('hello dart learner').The main() function calls greet() using print(greet());.&lt;br&gt;
And the expected output is;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fju62qvxuzvnlb04j9gyc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fju62qvxuzvnlb04j9gyc.png" alt=" " width="800" height="40"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.2 Functions as First-Class Objects in Dart&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Dart, functions are first-class objects, meaning they can be treated just like any other variable or object in the language. This gives functions in Dart the following characteristics; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Be stored in a variable,&lt;/li&gt;
&lt;li&gt;Be passed to another function as an argument, and&lt;/li&gt;
&lt;li&gt;Be returned from another function.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2.2.1 Assigning a Function to a Variable&lt;/strong&gt; &lt;br&gt;
A function can be assigned to a variable, allowing it to be called later using that variable name.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhdyv553qa2mwoxryz3yd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhdyv553qa2mwoxryz3yd.png" alt=" " width="800" height="61"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The image above show a random function &lt;code&gt;sayHello()&lt;/code&gt;.&lt;br&gt;
 Continuation on the same &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F61n1795jceq2udep7h1r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F61n1795jceq2udep7h1r.png" alt=" " width="800" height="155"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, the function &lt;code&gt;sayHello()&lt;/code&gt; is assigned to a variable &lt;code&gt;greetFunc&lt;/code&gt;. This allows you to call the function later using the variable name instead of the original function name.&lt;br&gt;
When you call &lt;code&gt;greetFunc()&lt;/code&gt;, the output will be:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3gauyfo2k4tcf83tws6i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3gauyfo2k4tcf83tws6i.png" alt=" " width="800" height="22"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.2.2 Passing a Function to Another Function&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Functions in Dart can also be passed as arguments to other functions.&lt;br&gt;
This is particularly useful for callbacks, event handling, and customizing behavior dynamically.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj8pn73dcpj09d3u0czgt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj8pn73dcpj09d3u0czgt.png" alt=" " width="800" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here’s a visual illustration of passing a function as an argument:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flbceyzveg7efgomcqa4c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flbceyzveg7efgomcqa4c.png" alt=" " width="800" height="48"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The expected output;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhvpwzcb0gjb7crzeisyy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhvpwzcb0gjb7crzeisyy.png" alt=" " width="572" height="28"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.2.3. Functions with a return value&lt;/strong&gt;&lt;br&gt;
A function can also return a value after performing its task.&lt;br&gt;
If a function is declared as void, it means it does not return anything. &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4x1oao559u2dihvinvmf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4x1oao559u2dihvinvmf.png" alt=" " width="800" height="108"&gt;&lt;/a&gt;&lt;br&gt;
Here is the output when the function is void;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0pdcb9pd78gys3gfkh9p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0pdcb9pd78gys3gfkh9p.png" alt=" " width="800" height="80"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the example below, we use the type bool to indicate that the function returns a Boolean value (true or false).&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2yu9q6vpe04kczmr5wcq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2yu9q6vpe04kczmr5wcq.png" alt=" " width="800" height="80"&gt;&lt;/a&gt;&lt;br&gt;
When arguments are passed into the function&lt;code&gt;isEven()&lt;/code&gt; remember we use the &lt;code&gt;print()&lt;/code&gt; to have the output displayed on the terminal&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ja3x3wnihltagpqvgxa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ja3x3wnihltagpqvgxa.png" alt=" " width="800" height="65"&gt;&lt;/a&gt;&lt;br&gt;
The expected output is;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhpabbitu00hnl1nv5i39.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhpabbitu00hnl1nv5i39.png" alt=" " width="800" height="30"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.3 Parameters in Functions&lt;/strong&gt;&lt;br&gt;
Parameters act as inputs that a function receives during invocation. &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F19g48tzf1hodwkgax2ts.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F19g48tzf1hodwkgax2ts.png" alt=" " width="800" height="97"&gt;&lt;/a&gt;&lt;br&gt;
In the illustration above, &lt;code&gt;String name&lt;/code&gt; inside the parentheses &lt;code&gt;()&lt;/code&gt; is a parameter. That acts as a placeholder for the argument (the actual value) passed during the function call.&lt;br&gt;
Parameters allow the function to process variable data instead of being limited to fixed values.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2d0f1gun0xax825zupac.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2d0f1gun0xax825zupac.png" alt=" " width="635" height="31"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Expected output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuk0n1dqjmxp9kss2khj1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuk0n1dqjmxp9kss2khj1.png" alt=" " width="700" height="27"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There several types of parameters used in functions:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.3.1 Positional Parameters&lt;/strong&gt;&lt;br&gt;
Positional parameters are the most basic type of function parameters.&lt;br&gt;
They must be passed in the same order they are defined in the function declaration.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F07f23i9o7ryw6o1jcdbc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F07f23i9o7ryw6o1jcdbc.png" alt=" " width="800" height="86"&gt;&lt;/a&gt;&lt;br&gt;
When calling the function the order matters.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxr0h22vvsi9gt9dbcfuv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxr0h22vvsi9gt9dbcfuv.png" alt=" " width="800" height="81"&gt;&lt;/a&gt;&lt;br&gt;
In the code above, notice the commented-out section — it shows an error caused by incorrect parameter order and if executed this is the output is.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn6c4cyt6olgd34kn92k5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn6c4cyt6olgd34kn92k5.png" alt=" " width="800" height="123"&gt;&lt;/a&gt;&lt;br&gt;
But if the parameters are correctly order the output is;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5mo4c6fgjzb6crq5m7tl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5mo4c6fgjzb6crq5m7tl.png" alt=" " width="800" height="23"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.3.2 Named Parameters { }&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Named parameters are enclosed in curly braces &lt;code&gt;{}&lt;/code&gt; and allow arguments to be specified by name.&lt;br&gt;
This enhances code readability and flexibility, especially when dealing with many parameters.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb9t3dgr5ndm6wjro44fq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb9t3dgr5ndm6wjro44fq.png" alt=" " width="800" height="80"&gt;&lt;/a&gt;&lt;br&gt;
Named parameters are optional by default, but they can be made required using the&lt;code&gt;required&lt;/code&gt; keyword.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv2jocdg43lkb904m8s66.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv2jocdg43lkb904m8s66.png" alt=" " width="800" height="70"&gt;&lt;/a&gt;&lt;br&gt;
They can also have default values using the &lt;code&gt;=&lt;/code&gt; operator.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbqnfdgg5ca45uc4blgl2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbqnfdgg5ca45uc4blgl2.png" alt=" " width="800" height="76"&gt;&lt;/a&gt;&lt;br&gt;
The image below shows illustrations on the named parameters on different functions being invoked(&lt;em&gt;read the comments they can help guide you&lt;/em&gt;) &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu3bywp0fzsqr3bzwvnh2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu3bywp0fzsqr3bzwvnh2.png" alt=" " width="795" height="188"&gt;&lt;/a&gt;&lt;br&gt;
And the expected outcome respectively;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzzyckd20y4e7oy7i4vrw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzzyckd20y4e7oy7i4vrw.png" alt=" " width="715" height="101"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Optional Positional Parameters &lt;code&gt;[ ]&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Optional positional parameters allow you to make some function parameters optional by enclosing them in square brackets [ ].&lt;br&gt;
If the caller doesn’t provide a value for these parameters, they take on a default value (if one is specified) or become null by default.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqfmthu976d9uc7z7grkp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqfmthu976d9uc7z7grkp.png" alt=" " width="800" height="175"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The arguements passed in the function.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fctx44zjoyjox0gc2f0v2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fctx44zjoyjox0gc2f0v2.png" alt=" " width="760" height="64"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Excepted output;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4xde6rdin0zyhiiz2rwf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4xde6rdin0zyhiiz2rwf.png" alt=" " width="800" height="39"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;3. Function Scope in Dart&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Scope defines where variables and functions can be accessed within a program. Variables can be defined as global, local, or nested, depending on where they are declared.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.1 Global Scope&lt;/strong&gt;&lt;br&gt;
A variable declared outside any function or class has global scope, meaning it can be accessed from anywhere within the same file. As shown in the image below.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feodhpn84c8rai5xbhbey.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feodhpn84c8rai5xbhbey.png" alt=" " width="800" height="85"&gt;&lt;/a&gt;&lt;br&gt;
The variable &lt;code&gt;String greeting&lt;/code&gt;which is defined outside the main function (&lt;em&gt;inside the global scope&lt;/em&gt;)can be accessed in the scope of the &lt;code&gt;main()&lt;/code&gt; function using &lt;code&gt;print(greeting)&lt;/code&gt;, and the expected output is:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs90su9mne4pwnx8rzlgb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs90su9mne4pwnx8rzlgb.png" alt=" " width="576" height="30"&gt;&lt;/a&gt;&lt;br&gt;
Reason being the variable greeting is defined globally and can be accessed within any function in the same file.&lt;/p&gt;

&lt;p&gt;** 3.2 Local scope**&lt;br&gt;
A local variable is declared inside a function or block. It can only be accessed within that specific function. Here is an illustration on the same.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fte5reb3qva20sb5v1sj4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fte5reb3qva20sb5v1sj4.png" alt=" " width="655" height="89"&gt;&lt;/a&gt;&lt;br&gt;
The image above shows a &lt;code&gt;sayHello()&lt;/code&gt; function with a variable &lt;code&gt;String message&lt;/code&gt; defined inside it's scope.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpv39ji3vrj1nhmn8vqf1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpv39ji3vrj1nhmn8vqf1.png" alt=" " width="645" height="170"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we try to access the variable inside the &lt;code&gt;main()&lt;/code&gt; function using the &lt;code&gt;print(message)&lt;/code&gt; we get an error&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frqy9d649ht5nce6s87p8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frqy9d649ht5nce6s87p8.png" alt=" " width="707" height="56"&gt;&lt;/a&gt;&lt;br&gt;
The error occurs because I am attempting to access a variable that is outside the scope of the &lt;code&gt;main()&lt;/code&gt;function. But, when we call the function itself inside the main function the output is:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu5gffw4jp9bttutckdfs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu5gffw4jp9bttutckdfs.png" alt=" " width="710" height="20"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.3 Lexical Scope&lt;/strong&gt;&lt;br&gt;
Dart uses lexical (or static) scope, which means that variable visibility is determined by where the variables and functions are written in the code, not by where they are called at runtime.&lt;br&gt;
Each function can access variables defined in its enclosing scope.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhe4dmdg8djlqxvb2nz20.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhe4dmdg8djlqxvb2nz20.png" alt=" " width="800" height="305"&gt;&lt;/a&gt;&lt;br&gt;
The &lt;code&gt;innerFunction()&lt;/code&gt; function can access the variables both in the scope of the &lt;code&gt;main()&lt;/code&gt; and the &lt;code&gt;outerFunction()&lt;/code&gt; &lt;code&gt;String name&lt;/code&gt; and &lt;code&gt;int age&lt;/code&gt;respectively&lt;br&gt;
This is because &lt;code&gt;innerFunction()&lt;/code&gt; is lexically enclosed within &lt;code&gt;main()&lt;/code&gt; and the &lt;code&gt;outerFunction()&lt;/code&gt;, giving it access to all variables defined in it outer/enclosed scope.&lt;br&gt;
Illustrating Dart’s lexical scoping rule, where a function can “see” variables in its surrounding scopes, but not vice versa.&lt;br&gt;
expected output is:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5crtmzjfcdohd4nhel54.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5crtmzjfcdohd4nhel54.png" alt=" " width="486" height="34"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Reflection.
&lt;/h2&gt;

&lt;p&gt;Throughout this exploration of functions in Dart, several key lessons emerge that deepen both conceptual understanding and practical application in programming. Functions allow developers to write cleaner, modular code that is easy to maintain and debug. The main() Function is the Entry Point of Every Dart Program where execution begins. Moreover, functions in Dart are First-Class Objects meaning they can be stored in variables, passed as arguments, or even returned from other functions.&lt;br&gt;
In essence, understanding how functions work from their structure, invocation, and scope to their role in code organization is fundamental to becoming a proficient developer.&lt;br&gt;
Understanding these principles equips one with not only to write better code but also to design systems that are scalable, efficient, and easy to maintain.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Understanding Classes and Objects in Dart</title>
      <dc:creator>Raphael Kihiro</dc:creator>
      <pubDate>Mon, 10 Nov 2025 07:02:48 +0000</pubDate>
      <link>https://dev.to/kihiro/understanding-classes-and-objects-in-dart-3ml</link>
      <guid>https://dev.to/kihiro/understanding-classes-and-objects-in-dart-3ml</guid>
      <description>&lt;h2&gt;
  
  
  1. Introduction
&lt;/h2&gt;

&lt;p&gt;In object-oriented programming (OOP), classes serve as the fundamental building blocks for creating objects. A class acts as a blueprint that defines the properties (data) and behaviors(methods) that its objects will possess. &lt;br&gt;
By using classes, Dart allows programmers to organize related variables and functions into a single logical unit. This approach supports core OOP principles: abstraction, encapsulation, inheritance, and polymorphism, making applications easier to manage and scale.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Structure and Syntax of a Class.
&lt;/h2&gt;

&lt;p&gt;A class in Dart defines the structure of an object by grouping related data (variables) and behavior (methods) together.&lt;br&gt;
Each class can include:&lt;br&gt;
&lt;strong&gt;Instance variables&lt;/strong&gt; – attributes or data that belong to each object.&lt;br&gt;
&lt;strong&gt;Constructors&lt;/strong&gt; – special functions that initialize new objects.&lt;br&gt;
&lt;strong&gt;Methods&lt;/strong&gt; – functions that define how an object behaves.&lt;/p&gt;

&lt;p&gt;Below is an example of a simple Dart class definition:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fllosxsjqbukbq3zg9mx2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fllosxsjqbukbq3zg9mx2.png" alt=" " width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;class Person&lt;/code&gt; defines a blueprint for creating Person objects.&lt;br&gt;
It’s important to note that in the instance variables &lt;code&gt;String? name, age&lt;/code&gt;, the &lt;code&gt;?&lt;/code&gt; symbol indicates that the string is nullable, meaning it can hold either a string value or null, and the constructor initializes the variables &lt;code&gt;name&lt;/code&gt;,&lt;code&gt;gender&lt;/code&gt;, and &lt;code&gt;age&lt;/code&gt; whenever a new object is created.&lt;/p&gt;

&lt;p&gt;As demonstrated in the image below inside the main function:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu9d8ewosni12tjmvi1pl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu9d8ewosni12tjmvi1pl.png" alt=" " width="800" height="124"&gt;&lt;/a&gt;&lt;br&gt;
The &lt;code&gt;showdata()&lt;/code&gt; method above prints out information about the person and the variable p1 creates a new instance of the &lt;code&gt;Person&lt;/code&gt;class with &lt;code&gt;name&lt;/code&gt; set to “Raph,” &lt;code&gt;gender&lt;/code&gt;to “male,” and &lt;code&gt;age&lt;/code&gt; to 24.&lt;br&gt;
When the code is executed, the expected output will be:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fygz47w3uangp9vhmh3rz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fygz47w3uangp9vhmh3rz.png" alt=" " width="800" height="42"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Creating and Using Objects in Dart
&lt;/h2&gt;

&lt;p&gt;Once a class is defined, we can create objects  from it.&lt;br&gt;
An object is a specific, usable copy of a class that stores real data in memory.&lt;br&gt;
You can think of a class as a blueprint, and each object as a real product built from that blueprint (class).To illustrate,follow the simple Car class.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcm566hlot4ansvjflys5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcm566hlot4ansvjflys5.png" alt=" " width="800" height="295"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Car class serves as a blueprint for creating objects. As demonstrated below in the main() function:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fziibl3mi1otwry2585x0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fziibl3mi1otwry2585x0.png" alt=" " width="772" height="207"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, car1 and car2 are objects created from the Car class. You can create as many objects as needed, each with its own set of values for the properties defined in the class.&lt;/p&gt;

&lt;p&gt;When the code is executed, the expected output is:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwiw7ggyyb5wpts7go157.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwiw7ggyyb5wpts7go157.png" alt=" " width="800" height="48"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Constructors
&lt;/h2&gt;

&lt;p&gt;A constructor is a special method in Dart that is automatically called when an object of a class is created.&lt;br&gt;
Its main purpose is to initialize object properties and prepare the instance for use. Some of the existing constructors are:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.1 Generative Constructors&lt;/strong&gt;&lt;br&gt;
A generative constructor is the most common form. It creates a new instance every time it is called. This type allows initializing instance variables either directly or through parameters.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Firen17ayamta6ct2evrf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Firen17ayamta6ct2evrf.png" alt=" " width="800" height="247"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, every time you call Student(name age ), a new Student obeject is created.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feys4py7qoxe9v748xxjq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feys4py7qoxe9v748xxjq.png" alt=" " width="800" height="70"&gt;&lt;/a&gt;&lt;br&gt;
The expected output&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd9hij5weei7h9z8c6jc1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd9hij5weei7h9z8c6jc1.png" alt=" " width="800" height="28"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.2 Default Constructor&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If no constructor is not explicitly defined, Dart automatically provides a default constructor that takes no arguments and does nothing other than create the object.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv1697is0jrqbu95vek6q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv1697is0jrqbu95vek6q.png" alt=" " width="800" height="153"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the image above there are no constructors defined in the &lt;code&gt;class Animal&lt;/code&gt;. But you create an object like so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5v4swh1fsfbi275x2ujp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5v4swh1fsfbi275x2ujp.png" alt=" " width="800" height="123"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is possible to create objects since dart provides a default constructor and if we call the method &lt;code&gt;a.speak()&lt;/code&gt;. the expected output is;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe8g39gn0tn6h8659m24v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe8g39gn0tn6h8659m24v.png" alt=" " width="800" height="34"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.3 Parameterized Constructor&lt;/strong&gt;&lt;br&gt;
A parameterized constructor allows you to pass data when creating an object.&lt;br&gt;
This is the most common constructor type in Dart.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbr1l3dj3t4wszs49ze3b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbr1l3dj3t4wszs49ze3b.png" alt=" " width="800" height="251"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you create an object or 2 then call the method.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxsbk1i392x2lw7jv93fx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxsbk1i392x2lw7jv93fx.png" alt=" " width="800" height="109"&gt;&lt;/a&gt;&lt;br&gt;
 The expected out-put is.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcm414b2k5prfzl9fxdla.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcm414b2k5prfzl9fxdla.png" alt=" " width="800" height="38"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Methods in Dart
&lt;/h2&gt;

&lt;p&gt;Methods are functions that belong to a class and define the behavior of its objects. They enable objects to perform actions, manipulate data, or communicate with other objects.&lt;/p&gt;

&lt;p&gt;Dart supports two main categories of methods: instance methods and class (static) methods.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5.1 Instance Methods&lt;/strong&gt;&lt;br&gt;
An instance method operates on the data of a specific object.&lt;br&gt;
To call an instance method, one must first create an instance of the class.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4vo1s0bo11o70rjgdj4w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4vo1s0bo11o70rjgdj4w.png" alt=" " width="800" height="173"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, &lt;code&gt;displayInfo()&lt;/code&gt; is an instance method because it depends on the instance’s &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;marks&lt;/code&gt;. Each Student object created has its own version data.(the instance method is called on instance variables in this case &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;marks&lt;/code&gt;)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpj0eugr7ebsuul27048u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpj0eugr7ebsuul27048u.png" alt=" " width="800" height="49"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Output &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw6i7ie7wnfzboxh02pwp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw6i7ie7wnfzboxh02pwp.png" alt=" " width="800" height="44"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5.2 Static (Class) Methods&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A static method belongs to the class itself, not to any object. It is declared using the &lt;code&gt;static&lt;/code&gt; keyword and can be called directly using the class name.&lt;/p&gt;

&lt;p&gt;Static methods cannot access instance variables or  instance methods directly — they can only work with static variables or parameters passed to them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2i3oplr109wlpn8x5ruo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2i3oplr109wlpn8x5ruo.png" alt=" " width="800" height="79"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this case &lt;code&gt;static double square&lt;/code&gt;that pick up the &lt;code&gt;double num&lt;/code&gt; as it's argument and when the method is called:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl4ld8fh48d4qr56yijwt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl4ld8fh48d4qr56yijwt.png" alt=" " width="800" height="26"&gt;&lt;/a&gt;&lt;br&gt;
The expected output is ;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3h1ky3a71roltl610qwq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3h1ky3a71roltl610qwq.png" alt=" " width="800" height="26"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Extending a Class (Inheritance)
&lt;/h2&gt;

&lt;p&gt;Sometimes, you’ll want one class to build upon another. That’s where inheritance comes in. Inheritance allows you to create a new class that reuses, extends, or modifies behavior of another class.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5g6ac4k9hj252f397ngx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5g6ac4k9hj252f397ngx.png" alt=" " width="800" height="162"&gt;&lt;/a&gt;&lt;br&gt;
When you create a &lt;code&gt;Dog&lt;/code&gt; object, it inherits the behavior of &lt;code&gt;Animal&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy5qitzehqaes2qud8bcr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy5qitzehqaes2qud8bcr.png" alt=" " width="723" height="141"&gt;&lt;/a&gt;&lt;br&gt;
You can override parent methods using &lt;a class="mentioned-user" href="https://dev.to/override"&gt;@override&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fschvyf6biuzx782rjoq8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fschvyf6biuzx782rjoq8.png" alt=" " width="800" height="100"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Mixins
&lt;/h2&gt;

&lt;p&gt;Inheritance isn’t the only way to share behavior Dart also supports mixins for more flexible code reuse. A mixin is a way to reuse code between classes without using inheritance.&lt;br&gt;
Think of it as “copy-pasting” shared methods into multiple classes safely.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F427kug7ngxkuj0oktlxs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F427kug7ngxkuj0oktlxs.png" alt=" " width="800" height="303"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Important points to note about mixins.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You use them with the with keyword.&lt;/li&gt;
&lt;li&gt;They don’t have constructors.&lt;/li&gt;
&lt;li&gt;You can combine multiple mixins.
Mixins are great for sharing behavior across unrelated classes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  8. Enums
&lt;/h2&gt;

&lt;p&gt;Enums (short for enumerations) are a way to represent a fixed number of constant values.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9t0aqzncxfzbuw5hlr5p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9t0aqzncxfzbuw5hlr5p.png" alt=" " width="800" height="150"&gt;&lt;/a&gt;&lt;br&gt;
Since Dart 2.17+, enums can contain methods, getters, and fields.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqceuaptxz6uflbthvt7s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqceuaptxz6uflbthvt7s.png" alt=" " width="800" height="230"&gt;&lt;/a&gt;&lt;br&gt;
Enums are perfect for representing states, modes, or fixed categories.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Extension Methods
&lt;/h2&gt;

&lt;p&gt;An extension method lets you add new behavior to existing types — without changing their source code. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd3k65ri8ch3h05ju1s7a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd3k65ri8ch3h05ju1s7a.png" alt=" " width="800" height="201"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Callable Objects
&lt;/h2&gt;

&lt;p&gt;In Dart, you can make a class callable like a function by defining a &lt;code&gt;call()&lt;/code&gt; method.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsmstpol44lfrbw4ezv3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsmstpol44lfrbw4ezv3.png" alt=" " width="800" height="174"&gt;&lt;/a&gt;&lt;br&gt;
Callable objects are especially useful when you want function like behavior but still need the structure of a class (for example, in state management or data transformers).&lt;/p&gt;

&lt;h2&gt;
  
  
  Reflection
&lt;/h2&gt;

&lt;p&gt;As I worked through these concepts, I realized that OOP in Dart is not just a set of rules—it’s a mindset. It encourages me to think more abstractly about problems, break them into manageable pieces, and design solutions that are both reusable and scalable.&lt;br&gt;
OOP features has allows me as a developer to approach Dart projects with a clearer structure, a stronger understanding of code organization, and a deeper appreciation of how to model real-world scenarios efficient way. This journey has not only expanded my technical skill set but has also shaped my thought process toward writing cleaner, more intentional code.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>LEARNING BASIC DART</title>
      <dc:creator>Raphael Kihiro</dc:creator>
      <pubDate>Tue, 14 Oct 2025 06:41:09 +0000</pubDate>
      <link>https://dev.to/kihiro/learning-basic-dart-41nd</link>
      <guid>https://dev.to/kihiro/learning-basic-dart-41nd</guid>
      <description>&lt;p&gt;&lt;a href="https://dev.tourl"&gt;&lt;/a&gt;&lt;strong&gt;Introduction to dart&lt;/strong&gt;&lt;br&gt;
Dart is a modern, object-oriented programming language developed by Google. It’s designed to be easy to learn, fast, and versatile, powering everything from mobile apps (using Flutter) to web and backend development.&lt;/p&gt;

&lt;p&gt;From my experience, Dart’s syntax feels very familiar if you’ve worked with languages like JavaScript; it’s clean, intuitive, and beginner friendly. At the same time, it offers powerful features that make it an excellent choice for both beginners learning programming concepts and professionals building large-scale applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Learn Dart&lt;/strong&gt;&lt;br&gt;
From what I have gather in my first week learning the language:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Dart is a modern, object-oriented programming language developed by Google as an improvement over the popular JavaScript. It’s designed to be fast, powerful, and easy to learn, making it ideal for everything from web to backend and mobile app development.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Dart is a beast when it comes to building highly optimized backend systems especially in the hands of a skilled developer who has mastered its tools and features.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It also powers Flutter, one of the world’s most popular frameworks for cross-platform app development, allowing developers to build beautiful and efficient apps for Android, iOS, web, and desktop.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Learning Dart is a smart move for anyone interested in modern backend development. With Serverpod, Dart provides a clean, type-safe, and efficient way to build powerful server-side applications. It simplifies API creation, database integration, and communication — all while keeping your code fast, organized, and easy to maintain.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Basic Dart&lt;/strong&gt;&lt;br&gt;
As tradition dictates “Hello, World!” is the first program you write when learning a new programming language and here is how you go about it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Hello World&lt;/strong&gt;&lt;br&gt;
Every app requires the top-level function, where execution starts. Functions that don't explicitly return a value have the void return type. To display text on the console, you can use the top-level print() function.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4r0otieda5n97b670ada.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4r0otieda5n97b670ada.png" alt=" " width="800" height="184"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Variables in Dart&lt;/strong&gt;&lt;br&gt;
Variables store data that can be used, changed, and referenced throughout a program. In Dart, you declare variables using the var, final, or const keywords, depending on whether the value can change or not.&lt;/p&gt;

&lt;p&gt;It is also important to note that variables are declared similarly to JavaScript following the Carmel-case naming convention.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6th8wsgwjhzl7vrqm06d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6th8wsgwjhzl7vrqm06d.png" alt=" " width="542" height="62"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. var&lt;/strong&gt;&lt;br&gt;
the variable is used when the value can change. The image below  demonstrates its use case.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl7oghogbu4c225krecm6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl7oghogbu4c225krecm6.png" alt=" " width="752" height="118"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;b. final&lt;/strong&gt;&lt;br&gt;
final is a variable used when the value is set once and cannot be reassigned.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fry4mwpghh03m15a1eg5s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fry4mwpghh03m15a1eg5s.png" alt=" " width="751" height="136"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;c. const&lt;/strong&gt;&lt;br&gt;
The const variable is almost similar to the final variable declaration in that they both can not be reassigned, although the value in a const must be known and fixed when the program is compiled, not during execution. It’s ideal for values that will never change and are shared across the program, improving performance and memory efficiency.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsenpyan3lwx8tr0qbro6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsenpyan3lwx8tr0qbro6.png" alt=" " width="800" height="103"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is also important to note that variables in dart can be declared based on their data types to ensure type safety and clarity in your code. You can explicitly specify the type, such as int, double, String, bool, or List, to indicate the kind of data the variable will store, we will get into depth on this when we look at data types.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data types in dart&lt;/strong&gt;&lt;br&gt;
Data types in Dart define the kind of values a variable can hold and how those values are used in a program. They ensure that data is stored and processed correctly. Common data types in Dart include numbers, strings, booleans, lists, maps, and dynamic types each serving a unique purpose in representing and managing different kinds of information within your code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. Numbers&lt;/strong&gt;&lt;br&gt;
Numbers in Dart are used to represent numeric values. They come in two main types; int for whole numbers and double for decimal values.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ureuqcu60jvfvbtncm2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ureuqcu60jvfvbtncm2.png" alt=" " width="800" height="299"&gt;&lt;/a&gt;&lt;br&gt;
An integer can be converted from an integer to a double as illustrated below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ydsij9uhv3d4li9los8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ydsij9uhv3d4li9los8.png" alt=" " width="765" height="73"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b. Strings&lt;/strong&gt;&lt;br&gt;
Strings store text data and are enclosed in either single or double quotes. They can also include variables using string interpolation (e.g., "Hello $name").&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F88oy1ohzl6soi1tjemlu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F88oy1ohzl6soi1tjemlu.png" alt=" " width="800" height="171"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c. Booleans&lt;/strong&gt;&lt;br&gt;
Booleans represent logical values and can only be true or false. &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpjv7q1mvttreryv4866v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpjv7q1mvttreryv4866v.png" alt=" " width="800" height="172"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d. List&lt;/strong&gt;&lt;br&gt;
Lists are ordered collections of items, similar to arrays in other languages. They allow you to store multiple values in a single variable and access them by index.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frto5mkw970rnpxg32z1k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frto5mkw970rnpxg32z1k.png" alt=" " width="800" height="116"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lists in Dart are one of the most powerful and flexible data structures, allowing you to store and manipulate ordered collections of items. Dart lists are zero-indexed, meaning the first element starts at index 0, and you can access or update values using their index positions. You can add elements with methods like .add(), .addAll(), .insert(), or .insertAll(), and remove them using .remove(), .removeAt(), .removeLast(), or .clear(). Lists can also be searched using .contains() and .indexOf(), and organized using .sort(), .shuffle(), or .reversed. Dart makes it easy to loop through lists with for loops or .forEach(). Overall, Dart lists are incredibly versatile perfect for storing, modifying, and processing data efficiently in any program.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;e. Maps&lt;/strong&gt;&lt;br&gt;
Maps store data as key-value pairs, allowing quick lookups by key. &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu3ccr1lcp7lg1uwdzhz1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu3ccr1lcp7lg1uwdzhz1.png" alt=" " width="800" height="112"&gt;&lt;/a&gt;&lt;br&gt;
You can add, modify, or remove entries using methods like .addAll(), .remove(), and .clear(). Maps also let you view all keys and values, check for specific entries, and efficiently manage structured data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;f. Sets&lt;/strong&gt;&lt;br&gt;
Sets in Dart are unordered collections of unique items, meaning no duplicates are allowed. They’re useful when you need to store distinct values, like IDs or names.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4da2i28uimvvhjn08ndx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4da2i28uimvvhjn08ndx.png" alt=" " width="800" height="199"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;it is also important to note we can use the set constructor to change a list to a set &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgc0376w7x4kwddfepaix.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgc0376w7x4kwddfepaix.png" alt=" " width="800" height="194"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;g. Dynamic&lt;/strong&gt;&lt;br&gt;
A dynamic variable can hold values of any type, and its type can change at runtime. While it gives flexibility, it also removes compile-time type safety so it’s best used only when the data type isn’t known in advance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F06rjjd5u4ewjpgxiydru.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F06rjjd5u4ewjpgxiydru.png" alt=" " width="800" height="280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Operators in dart&lt;/strong&gt;&lt;br&gt;
Now that we have looked at data types in dart lets dig on some of the operators used in dart. Operators are special symbols used to perform operations on variables and values. They make it easier to write expressions for tasks like arithmetic, comparisons, and logic. Common types include arithmetic operators (+, -, *, /), comparison operators (==, !=, &amp;lt;, &amp;gt;), logical operators (&amp;amp;&amp;amp;, ||, !), and assignment operators (=, +=, -=).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ch3mfvv4ww0ic8caemi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ch3mfvv4ww0ic8caemi.png" alt=" " width="602" height="847"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Control flow
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Loops in Dart&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. For Loop&lt;/strong&gt;&lt;br&gt;
Repeats a block of code a fixed number of times.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq8hj9qdfvi61o53x87w6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq8hj9qdfvi61o53x87w6.png" alt=" " width="800" height="164"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b. For-in Loop&lt;/strong&gt;&lt;br&gt;
Used to iterate through elements in a collection like a list.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd2fxlszbr8ejaxggl9ej.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd2fxlszbr8ejaxggl9ej.png" alt=" " width="800" height="142"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c. While Loop&lt;/strong&gt;&lt;br&gt;
Executes while the condition is true (checked before the loop runs).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsvjtqiovsyry8m0s5hqb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsvjtqiovsyry8m0s5hqb.png" alt=" " width="800" height="172"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d. Do-While Loop&lt;/strong&gt;&lt;br&gt;
Runs the code at least once before checking the condition.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw1jiah0z50f4lhfmkfuy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw1jiah0z50f4lhfmkfuy.png" alt=" " width="800" height="123"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;e. Break Statement&lt;/strong&gt;&lt;br&gt;
Stops the loop immediately when a condition is met.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjtlzj1kk91pq8t852fh3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjtlzj1kk91pq8t852fh3.png" alt=" " width="800" height="356"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;f. Continue Statement&lt;/strong&gt;&lt;br&gt;
Skips the current iteration and moves to the next one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsqhp90wrmskp1qagttmy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsqhp90wrmskp1qagttmy.png" alt=" " width="787" height="476"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;2. Conditional statements&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. if Statement&lt;/strong&gt;&lt;br&gt;
Used to test if a condition is true before executing a block of code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1ogt32poabesaq1wwslz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1ogt32poabesaq1wwslz.png" alt=" " width="800" height="193"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b. else Statement&lt;/strong&gt;&lt;br&gt;
Runs when the if condition is not met. As illustrated by the image above&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c. else if Statement&lt;/strong&gt;&lt;br&gt;
Used to check multiple conditions one after another.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuzgru0li3n7rzoscshiq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuzgru0li3n7rzoscshiq.png" alt=" " width="800" height="203"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d. if-case Statement&lt;/strong&gt;&lt;br&gt;
Used for pattern matching in Dart (checks data structure patterns).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzf1oiqfm6d3om8tfmj7b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzf1oiqfm6d3om8tfmj7b.png" alt=" " width="800" height="172"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;e. switch Statement&lt;/strong&gt;&lt;br&gt;
Simplifies handling of multiple possible values for a variable.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fweczotfasgfleul6361g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fweczotfasgfleul6361g.png" alt=" " width="800" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion.
&lt;/h2&gt;

&lt;p&gt;I’ve just started learning Dart, and I decided to document and publish my progress both to help upcoming developers exploring the language and to track my own growth. So far, it’s been an exciting journey.  I’m already amazed by what it can do. I can’t wait to start building amazing projects with this tool, with the ultimate goal of using technology to solve real-world problems. Happy coding.&lt;/p&gt;

&lt;p&gt;You can follow along with my Dart learning journey and projects on &lt;a href="//github.com/raphaelkihiro/Dart"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

</description>
      <category>dart</category>
      <category>learning</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
