<?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: Colton Ehrman</title>
    <description>The latest articles on DEV Community by Colton Ehrman (@coltonehrman).</description>
    <link>https://dev.to/coltonehrman</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%2F355602%2Fcafbaec9-c72a-4c6f-99e1-36f4d25c7e79.JPG</url>
      <title>DEV Community: Colton Ehrman</title>
      <link>https://dev.to/coltonehrman</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/coltonehrman"/>
    <language>en</language>
    <item>
      <title>Flutter: User Auth with Firebase</title>
      <dc:creator>Colton Ehrman</dc:creator>
      <pubDate>Mon, 30 Mar 2020 01:51:41 +0000</pubDate>
      <link>https://dev.to/coltonehrman/flutter-user-auth-with-firebase-3dca</link>
      <guid>https://dev.to/coltonehrman/flutter-user-auth-with-firebase-3dca</guid>
      <description>&lt;p&gt;In this guide, I am going to walk through setting up a basic login screen that will authenticate with Firebase.&lt;/p&gt;

&lt;p&gt;To get started, set up a widget for the &lt;strong&gt;LoginScreen&lt;/strong&gt;. This widget will be &lt;em&gt;stateful&lt;/em&gt; and consist of fields to input an &lt;em&gt;email&lt;/em&gt; and a &lt;em&gt;password&lt;/em&gt;, and also a &lt;em&gt;submit button&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;lib/login_screen.dart&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:flutter/material.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;LoginScreen&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatefulWidget&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;LoginScreenState&lt;/span&gt; &lt;span class="n"&gt;createState&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;LoginScreenState&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;LoginScreenState&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;State&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;LoginScreen&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;emailField&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;TextField&lt;/span&gt;&lt;span class="o"&gt;(...);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;passwordField&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;TextField&lt;/span&gt;&lt;span class="o"&gt;(...);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;submitButton&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;TextField&lt;/span&gt;&lt;span class="o"&gt;(...);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Container&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;margin:&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;EdgeInsets&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;all&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;20.0&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Form&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Column&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
          &lt;span class="nl"&gt;children:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Widget&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;[&lt;/span&gt;
            &lt;span class="n"&gt;emailField&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
            &lt;span class="n"&gt;passwordField&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
            &lt;span class="n"&gt;submitButton&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
          &lt;span class="o"&gt;],&lt;/span&gt;
        &lt;span class="o"&gt;),&lt;/span&gt; &lt;span class="c1"&gt;// Column&lt;/span&gt;
      &lt;span class="o"&gt;),&lt;/span&gt; &lt;span class="c1"&gt;// Form&lt;/span&gt;
    &lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Container&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let's start working on the &lt;code&gt;emailField&lt;/code&gt; and &lt;code&gt;passwordField&lt;/code&gt; methods to get something to display out on the screen.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="nf"&gt;emailField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;TextFormField&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
    &lt;span class="nl"&gt;decoration:&lt;/span&gt; &lt;span class="n"&gt;InputDecoration&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;labelText:&lt;/span&gt; &lt;span class="s"&gt;'Email'&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;hintText:&lt;/span&gt; &lt;span class="s"&gt;'john.doe@gmail.com'&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
    &lt;span class="o"&gt;),&lt;/span&gt;
    &lt;span class="nl"&gt;keyboardType:&lt;/span&gt; &lt;span class="n"&gt;TextInputType&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;emailAddress&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
  &lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="nf"&gt;passwordField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;TextFormField&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
    &lt;span class="nl"&gt;obscureText:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;decoration:&lt;/span&gt; &lt;span class="n"&gt;InputDecoration&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;labelText:&lt;/span&gt; &lt;span class="s"&gt;'Password'&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;hintText:&lt;/span&gt; &lt;span class="s"&gt;'8-12 characters long'&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
    &lt;span class="o"&gt;),&lt;/span&gt;
  &lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Our app should now look like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---lT_fV-Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/6gFKoRj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---lT_fV-Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/6gFKoRj.png" alt="Simulator screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, we are going to create the &lt;code&gt;submitButton&lt;/code&gt; widget, and give it some custom styling to make it look somewhat nice.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="nf"&gt;submitButton&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;accentColor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;HSLColor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fromColor&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Theme&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;accentColor&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="c1"&gt;// This will darken the Theme's accentColor by a factor of '0.5' percent&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;darkAccentColor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;accentColor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;withLightness&lt;/span&gt;&lt;span class="o"&gt;((&lt;/span&gt;&lt;span class="n"&gt;accentColor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;lightness&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;clamp&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="o"&gt;)).&lt;/span&gt;&lt;span class="na"&gt;toColor&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;RaisedButton&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
    &lt;span class="nl"&gt;onPressed:&lt;/span&gt; &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;{},&lt;/span&gt;
    &lt;span class="nl"&gt;textColor:&lt;/span&gt; &lt;span class="n"&gt;darkAccentColor&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;padding:&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;EdgeInsets&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;all&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
    &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Row&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;children:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Widget&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;[&lt;/span&gt;
        &lt;span class="n"&gt;Expanded&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
          &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Container&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
            &lt;span class="nl"&gt;decoration:&lt;/span&gt; &lt;span class="n"&gt;BoxDecoration&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
              &lt;span class="nl"&gt;color:&lt;/span&gt; &lt;span class="n"&gt;Theme&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;accentColor&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
            &lt;span class="o"&gt;),&lt;/span&gt; &lt;span class="c1"&gt;// BoxDecoration&lt;/span&gt;
            &lt;span class="nl"&gt;padding:&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;EdgeInsets&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;all&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;10.0&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
            &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
              &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
                &lt;span class="s"&gt;'Submit'&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
                &lt;span class="nl"&gt;style:&lt;/span&gt; &lt;span class="n"&gt;TextStyle&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;fontSize:&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
              &lt;span class="o"&gt;),&lt;/span&gt; &lt;span class="c1"&gt;// Text&lt;/span&gt;
            &lt;span class="o"&gt;),&lt;/span&gt; &lt;span class="c1"&gt;// Center&lt;/span&gt;
          &lt;span class="o"&gt;),&lt;/span&gt; &lt;span class="c1"&gt;// Container&lt;/span&gt;
        &lt;span class="o"&gt;),&lt;/span&gt; &lt;span class="c1"&gt;// Expanded&lt;/span&gt;
      &lt;span class="o"&gt;],&lt;/span&gt;
    &lt;span class="o"&gt;),&lt;/span&gt; &lt;span class="c1"&gt;// Row&lt;/span&gt;
  &lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// RaisedButton&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now the app should look like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dFzudob2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/xGkIVvC.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dFzudob2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/xGkIVvC.png" alt="Simulator screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;To be continued...&lt;/em&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>authentication</category>
      <category>firebase</category>
    </item>
    <item>
      <title>Flutter: Building Photo App</title>
      <dc:creator>Colton Ehrman</dc:creator>
      <pubDate>Sat, 28 Mar 2020 20:41:40 +0000</pubDate>
      <link>https://dev.to/coltonehrman/flutter-building-photo-app-eo9</link>
      <guid>https://dev.to/coltonehrman/flutter-building-photo-app-eo9</guid>
      <description>&lt;h4&gt;
  
  
  - &lt;a href="https://www.udemy.com/share/1013AABUobdVZUQXo=/"&gt;Course&lt;/a&gt; by Stephen Grider
&lt;/h4&gt;

&lt;h4&gt;
  
  
  - &lt;a href="https://github.com/coltonehrman/flutter-photo-app/tree/master"&gt;Project Repo&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;The course goes into great detail over every piece of code that is written in the App. With this walkthrough, I intend to only highlight the building process, and will not go into much detail. That part is best left to the instructor of the course. I'd like to thank him for the amazing material he releases to his students!&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting up Initial Project
&lt;/h3&gt;

&lt;p&gt;Let's set up the initial code project after running &lt;code&gt;flutter create [app_name]&lt;/code&gt;. We will clean up the default &lt;code&gt;main.dart&lt;/code&gt; file and add some new folders, files to help keep things organized in the project.&lt;/p&gt;

&lt;p&gt;To start off, we will need a &lt;code&gt;Stateful&lt;/code&gt; App, that contains a simple &lt;code&gt;Scaffold&lt;/code&gt; with the &lt;code&gt;appBar&lt;/code&gt;, &lt;code&gt;body&lt;/code&gt;, and &lt;code&gt;floatingActionButton&lt;/code&gt; all set. We will also add some dummy state data.&lt;/p&gt;

&lt;h4&gt;
  
  
  New File Structure
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lib/
  main.dart       # The main file with the 'main' function
  src/
   models/        # Will store our Dart Class data structures
   App.dart       # Our App starting point
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;lib/main.dart&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:flutter/material.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'./src/App.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;runApp&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;App&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;lib/src/App.dart&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:flutter/material.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;App&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatefulWidget&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;State&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;StatefulWidget&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;createState&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;AppState&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AppState&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;State&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;App&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;_imageCounter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

  &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;_addImage&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;setState&lt;/span&gt;&lt;span class="o"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="n"&gt;_imageCounter&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;});&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;MaterialApp&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;home:&lt;/span&gt; &lt;span class="n"&gt;Scaffold&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;appBar:&lt;/span&gt; &lt;span class="n"&gt;AppBar&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
          &lt;span class="nl"&gt;title:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Let&lt;/span&gt;&lt;span class="se"&gt;\'&lt;/span&gt;&lt;span class="s"&gt;s See Images!'&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
        &lt;span class="o"&gt;),&lt;/span&gt;
        &lt;span class="nl"&gt;body:&lt;/span&gt; &lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
          &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Image - &lt;/span&gt;&lt;span class="si"&gt;$_imageCounter&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
        &lt;span class="o"&gt;),&lt;/span&gt;
        &lt;span class="nl"&gt;floatingActionButton:&lt;/span&gt; &lt;span class="n"&gt;FloatingActionButton&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
          &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Icon&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Icons&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;add&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
          &lt;span class="nl"&gt;onPressed:&lt;/span&gt; &lt;span class="n"&gt;_addImage&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
        &lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="o"&gt;),&lt;/span&gt;
    &lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;em&gt;Complete code for this section on &lt;a href="https://github.com/coltonehrman/flutter-photo-app/tree/starter_code"&gt;repo&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As you can see we wrap our main Widget in a &lt;code&gt;MaterialApp&lt;/code&gt; which then has a &lt;code&gt;Scaffold&lt;/code&gt; to structure/layout the rest of the Widgets. We have an &lt;code&gt;AppBar&lt;/code&gt; to display the App's title at the top. Some &lt;code&gt;Text&lt;/code&gt; in the &lt;code&gt;Center&lt;/code&gt; of the screen to show you the App's current state. Then a &lt;code&gt;FloatingActionButton&lt;/code&gt; that will trigger a &lt;code&gt;setState&lt;/code&gt; when pressed.&lt;/p&gt;

&lt;p&gt;The next step will be to implement code that interacts with the image API we will be using - &lt;a href="https://jsonplaceholder.typicode.com/photos"&gt;https://jsonplaceholder.typicode.com/photos&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We will be using the &lt;a href="https://pub.dev/packages/http"&gt;&lt;strong&gt;http&lt;/strong&gt;&lt;/a&gt; package to make sending the requests to the API easier to work with. &lt;em&gt;Don't forget to add the package to the projects &lt;code&gt;pubspec.yaml&lt;/code&gt; file.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Before we implement the code to interact with the API, let's set up our data model to consume the API.&lt;/p&gt;
&lt;h4&gt;
  
  
  New File
&lt;/h4&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lib/
  src/
   models/
    ImageModel.dart # New file
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;lib/src/models/ImageModel.dart&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ImageModel&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

  &lt;span class="n"&gt;ImageModel&lt;/span&gt;&lt;span class="o"&gt;({&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;url&lt;/span&gt; &lt;span class="o"&gt;});&lt;/span&gt;

  &lt;span class="n"&gt;ImageModel&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fromJSON&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Map&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;dynamic&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;encodedJSON&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;encodedJSON&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'id'&lt;/span&gt;&lt;span class="o"&gt;];&lt;/span&gt;
    &lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;encodedJSON&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'title'&lt;/span&gt;&lt;span class="o"&gt;];&lt;/span&gt;
    &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;encodedJSON&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'url'&lt;/span&gt;&lt;span class="o"&gt;];&lt;/span&gt;  
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;This model will be used to consume the API that we will be using. We set up two constructors, one that can be passed the data directly, and another that will accept JSON data.&lt;/p&gt;

&lt;p&gt;Now we are ready to fetch the API for some JSON data.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;To save on space and not clutter this article I will only be presenting updates to files that have already been created, instead of showing the whole file&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Updated File
&lt;/h4&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lib/
  src/
    App.dart # Updated file
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;em&gt;Updates&lt;/em&gt; to &lt;strong&gt;lib/src/App.dart&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="c1"&gt;// for decoding raw json data `json.decode()`&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'dart:convert'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;                   &lt;span class="c1"&gt;// new import&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:flutter/material.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:http/http.dart'&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// new import&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'./models/ImageModel.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;       &lt;span class="c1"&gt;// new import&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AppState&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;State&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;App&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// fetches the image JSON data from the API&lt;/span&gt;
  &lt;span class="c1"&gt;// will return the raw json decoded using `json.decode`&lt;/span&gt;
  &lt;span class="kd"&gt;dynamic&lt;/span&gt; &lt;span class="n"&gt;_fetchImage&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="n"&gt;async&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;imageAPI&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'https://jsonplaceholder.typicode.com/photos/&lt;/span&gt;&lt;span class="si"&gt;$_imageCounter&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;await&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;imageAPI&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;decode&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;// handler for when `FloatingActionButton` is pressed&lt;/span&gt;
  &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;_addImage&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="n"&gt;async&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;await&lt;/span&gt; &lt;span class="n"&gt;_fetchImage&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;           &lt;span class="c1"&gt;// fetch the data from API&lt;/span&gt;
    &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;newImage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ImageModel&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fromJSON&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// consume API&lt;/span&gt;

    &lt;span class="n"&gt;setState&lt;/span&gt;&lt;span class="o"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="n"&gt;_imageCounter&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;});&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;em&gt;Complete code for this section on &lt;a href="https://github.com/coltonehrman/flutter-photo-app/tree/image-api"&gt;repo&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now that we have consumed the photo API, we need to create a Widget to display the data we receive.&lt;/p&gt;

&lt;p&gt;Let's create an &lt;code&gt;ImageList&lt;/code&gt; Widget to hold all the data we fetch and display something on the App with it.&lt;/p&gt;
&lt;h4&gt;
  
  
  New File
&lt;/h4&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lib/
  src/
   widgets/ # New folder
    ImageList.dart # New file
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;lib/src/widgets/ImageList.dart&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:flutter/material.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'../models/ImageModel.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ImageList&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatelessWidget&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ImageModel&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;_images&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

  &lt;span class="n"&gt;ImageList&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;_images&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;_renderImages&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_images&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;length&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'No Images!'&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;ListView&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;builder&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;itemCount:&lt;/span&gt; &lt;span class="n"&gt;_images&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;itemBuilder:&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_images&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;].&lt;/span&gt;&lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
      &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Container&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;_renderImages&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
      &lt;span class="o"&gt;),&lt;/span&gt;
    &lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;We are using the &lt;code&gt;ListView.builder&lt;/code&gt; constructor to build a dynamic scrollable list for the images. We still do not have a proper Image UI in place. But, now you visually see the API being consumed by the application upon user interaction.&lt;/p&gt;

&lt;p&gt;Next, we will update the &lt;em&gt;App.dart&lt;/em&gt; file to use our new custom Widget.&lt;/p&gt;
&lt;h4&gt;
  
  
  Updated File
&lt;/h4&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lib/
  src/
    App.dart # Updated File
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;em&gt;Updates&lt;/em&gt; to &lt;strong&gt;lib/src/App.dart&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'dart:convert'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:flutter/material.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:http/http.dart'&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'./models/ImageModel.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'./widgets/ImageList.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// new import&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AppState&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;State&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;App&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;dynamic&lt;/span&gt; &lt;span class="n"&gt;_fetchImage&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="n"&gt;async&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// moved the imageCounter incrememting to here to prevent&lt;/span&gt;
    &lt;span class="c1"&gt;// consecutive calls overlapping before the Future resolves&lt;/span&gt;
    &lt;span class="c1"&gt;// and making app fetch the same image more than once&lt;/span&gt;
    &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;imageAPI&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'https://jsonplaceholder.typicode.com/photos/&lt;/span&gt;&lt;span class="si"&gt;${_imageCounter++}&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;await&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;imageAPI&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;decode&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;_addImage&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="n"&gt;async&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;await&lt;/span&gt; &lt;span class="n"&gt;_fetchImage&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;newImage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ImageModel&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fromJSON&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="c1"&gt;// modified setState&lt;/span&gt;
    &lt;span class="n"&gt;setState&lt;/span&gt;&lt;span class="o"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;_images&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;add&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;newImage&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;MaterialApp&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;home:&lt;/span&gt; &lt;span class="n"&gt;Scaffold&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;appBar:&lt;/span&gt; &lt;span class="n"&gt;AppBar&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
          &lt;span class="nl"&gt;title:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Let&lt;/span&gt;&lt;span class="se"&gt;\'&lt;/span&gt;&lt;span class="s"&gt;s See Images!'&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
        &lt;span class="o"&gt;),&lt;/span&gt;
        &lt;span class="nl"&gt;body:&lt;/span&gt; &lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
          &lt;span class="c1"&gt;// updated child to be our custom Widget&lt;/span&gt;
          &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;ImageList&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_images&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
        &lt;span class="o"&gt;),&lt;/span&gt;
        &lt;span class="nl"&gt;floatingActionButton:&lt;/span&gt; &lt;span class="n"&gt;FloatingActionButton&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
          &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Icon&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Icons&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;add&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
          &lt;span class="nl"&gt;onPressed:&lt;/span&gt; &lt;span class="n"&gt;_addImage&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
        &lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="o"&gt;),&lt;/span&gt;
    &lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;We have updated our App to include the new custom Widget we built, and also fixed a small bug that caused the &lt;code&gt;_fetchImage&lt;/code&gt; handler to be called consecutively and fetch the same image more than once. &lt;em&gt;See if you can figure out what was causing the bug, and why the new code fixes it.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;To be continued...&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Follow my journey of learning flutter!
&lt;/h4&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/coltonehrman" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1CHx3TVk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--Fs5Bgvz2--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/355602/cafbaec9-c72a-4c6f-99e1-36f4d25c7e79.JPG" alt="coltonehrman image"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/coltonehrman/learning-journey-flutter-488" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Learning Journey - Flutter&lt;/h2&gt;
      &lt;h3&gt;Colton Ehrman ・ Mar 27 ・ 7 min read&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#learning&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#flutter&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#dart&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;



</description>
      <category>flutter</category>
    </item>
    <item>
      <title>Learning Journey - Flutter</title>
      <dc:creator>Colton Ehrman</dc:creator>
      <pubDate>Fri, 27 Mar 2020 01:50:13 +0000</pubDate>
      <link>https://dev.to/coltonehrman/learning-journey-flutter-488</link>
      <guid>https://dev.to/coltonehrman/learning-journey-flutter-488</guid>
      <description>&lt;p&gt;I've been wanting to start documenting what I am learning and write down more content lately. This seems like the perfect opportunity to do so!&lt;/p&gt;

&lt;p&gt;My friend introduced me to Flutter after showing me an app that he put together in several months. After checking out how slick the app was, I was intrigued. I had already made a couple of apps using Swift, and React Native, but nothing that looked as good as this one. &lt;em&gt;(of course maybe he's just better at making apps than I am)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Several weeks have passed, I had looked into a couple of articles about Flutter and skimmed through the &lt;a href="https://flutter.dev"&gt;official docs&lt;/a&gt; but hadn't really decided to take the dive to start learning it. After having begged me to start learning flutter and proposing to work on a project together with me involving flutter and machine learning, my friend's persistence finally paid off.&lt;/p&gt;

&lt;p&gt;A couple of days ago, I went ahead and bought two courses on Udemy, one by  &lt;a href="https://www.udemy.com/share/1013AABUobdVZUQXo=/"&gt;Stephen Grider&lt;/a&gt; and another by &lt;a href="https://www.udemy.com/share/1013o4BUobdVZUQXo=/"&gt;Maximilian Schwarzmüller&lt;/a&gt;. My friend recommended that I get a course by &lt;a href="https://www.udemy.com/share/101WB6BUobdVZUQXo=/"&gt;Dr. Angela Yu&lt;/a&gt;, but my stubbornness chose to pick something else.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary Of The Courses I Got
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;by Stephen Grider&lt;/strong&gt;&lt;br&gt;
In my opinion, &lt;em&gt;from past experience with his courses&lt;/em&gt;, Stephen is really good at explaining &lt;strong&gt;how&lt;/strong&gt; something works. Instead of just teaching you how to do something, he teaches you why it works and goes deeper into the topic to give you a better understanding.&lt;/p&gt;
&lt;h2&gt;
  
  
  What I Learned So Far
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Dart Sections
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
Background

&lt;ul&gt;
&lt;li&gt;What is Dart &amp;amp; Flutter&lt;/li&gt;
&lt;li&gt;Dart Overview&lt;/li&gt;
&lt;li&gt;Online Dart Editor&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;First Program&lt;/li&gt;
&lt;li&gt;Function Syntax&lt;/li&gt;
&lt;li&gt;Variable Syntax&lt;/li&gt;
&lt;li&gt;Initializing Variables&lt;/li&gt;
&lt;li&gt;
String Interpolation

&lt;ul&gt;
&lt;li&gt;Weird Example&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Classes

&lt;ul&gt;
&lt;li&gt;Creating A Class&lt;/li&gt;
&lt;li&gt;Class Constructors&lt;/li&gt;
&lt;li&gt;Special Constructor&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Objects

&lt;ul&gt;
&lt;li&gt;Creating An Object&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Flutter Sections
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
Widgets

&lt;ul&gt;
&lt;li&gt;Common Widgets&lt;/li&gt;
&lt;li&gt;ListView&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Dart
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Background &lt;a&gt;&lt;/a&gt;
&lt;/h4&gt;
&lt;h5&gt;
  
  
  What is Dart &amp;amp; Flutter? &lt;a&gt;&lt;/a&gt;
&lt;/h5&gt;

&lt;p&gt;Dart is an Object-Oriented language, with syntax similar to JavaScript, and can optionally be transpiled into JavaScript code. Dart by itself, is just a programming language. Flutter is the framework that is used by Dart in order to build applications that run on Android and iOS.&lt;br&gt;
&lt;a href="https://dart.dev"&gt;Dart&lt;/a&gt; + &lt;a href="https://flutter.dev"&gt;Flutter&lt;/a&gt; = Cross-Platform App&lt;/p&gt;
&lt;h5&gt;
  
  
  Dart Overview &lt;a&gt;&lt;/a&gt;
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Object-Oriented language&lt;/li&gt;
&lt;li&gt;Statically typed language&lt;/li&gt;
&lt;li&gt;C-Style syntax&lt;/li&gt;
&lt;li&gt;Multiple Runtime Environments

&lt;ul&gt;
&lt;li&gt;Mobile Devices - Compiled to Machine Code&lt;/li&gt;
&lt;li&gt;Browser - Transpiled to JavaScript&lt;/li&gt;
&lt;li&gt;Command Line - Dart VM&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;
  
  
  Online Dart Compiler/Playground &lt;a&gt;&lt;/a&gt;
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://dartpad.dev/"&gt;DartPad&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  First Dart Program &lt;a&gt;&lt;/a&gt;
&lt;/h4&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Function declaration&lt;/span&gt;
&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;myName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;'Colton Ehrman'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Main function where program starts execution&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// variable initialization&lt;/span&gt;
  &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;myName&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
  &lt;span class="c1"&gt;// print something out&lt;/span&gt;
  &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'My name is &lt;/span&gt;&lt;span class="si"&gt;$name&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Function Syntax &lt;a&gt;&lt;/a&gt;
&lt;/h4&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Function Declaration / Definition&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Type&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;function&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;]([&lt;/span&gt;&lt;span class="n"&gt;parameters&lt;/span&gt;&lt;span class="o"&gt;])&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// [parameters] is optional&lt;/span&gt;
  &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;// [code] is any number expressions inside the curly braces&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Examples&lt;/span&gt;
&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;myName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;'Colton Ehrman'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// [return Type] is String&lt;/span&gt;
&lt;span class="c1"&gt;// [function name] is myName&lt;/span&gt;
&lt;span class="c1"&gt;// [parameters] is not provided - optional&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;printName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'My name is &lt;/span&gt;&lt;span class="si"&gt;$name&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// [return Type] is void&lt;/span&gt;
&lt;span class="c1"&gt;// [function name] is printName&lt;/span&gt;
&lt;span class="c1"&gt;// [parameters] is a single variable&lt;/span&gt;
&lt;span class="c1"&gt;//   String name&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Variable Syntax &lt;a&gt;&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;When using &lt;strong&gt;var&lt;/strong&gt; as the &lt;em&gt;[Type]&lt;/em&gt; in Dart, the type is inferred. &lt;em&gt;Although types are mandatory, type annotations are optional because of type inference. - &lt;a href="https://dart.dev/guides/language/sound-dart"&gt;Dart Type System&lt;/a&gt;&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Learn more on Dart Types&lt;/span&gt;
&lt;span class="c1"&gt;// https://dart.dev/guides/language/sound-dart&lt;/span&gt;

&lt;span class="c1"&gt;// Variable Declaration&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Type&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;variable&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;];&lt;/span&gt;

&lt;span class="c1"&gt;// Examples&lt;/span&gt;
&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// [Type] is String&lt;/span&gt;
&lt;span class="c1"&gt;// [variable name] is name&lt;/span&gt;

&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;anotherName&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// [Type] is var&lt;/span&gt;
&lt;span class="c1"&gt;// [variable name] is anotherName&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Initializing Variables &lt;a&gt;&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;When initializing a variable, you must match the &lt;em&gt;[Type]&lt;/em&gt; of the variable with the &lt;em&gt;[Type]&lt;/em&gt; of the value you are assigning to the variable. In cases where you do not explicitly define the &lt;em&gt;[Type]&lt;/em&gt; of the variable, Dart will use Type inference to determine the type. Once the &lt;em&gt;[Type]&lt;/em&gt; of a variable is set, you &lt;em&gt;cannot&lt;/em&gt; assign a value of a different &lt;em&gt;[Type]&lt;/em&gt; to that variable&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'Colton Ehrman'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// variable [name] of [Type] String is being assigned&lt;/span&gt;
&lt;span class="c1"&gt;// a value of 'Colton Ehrman' which is [Type] String&lt;/span&gt;

&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'Colton J. Ehrman'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// variable [name] is being re-assigned&lt;/span&gt;
&lt;span class="c1"&gt;// a new value of 'Colton J. Ehrman' which is [Type] String&lt;/span&gt;

&lt;span class="c1"&gt;// Error!&lt;/span&gt;
&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;123&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// invalid assignment of [Type] int to&lt;/span&gt;
&lt;span class="c1"&gt;// variable [name] with [Type] String&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  String Interpolation &lt;a&gt;&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;How Dart variables and/or expressions are interpolated - insert something of a different nature into something else - into Strings.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Strings in Dart are surrounded by either double quotes &lt;strong&gt;"[String]"&lt;/strong&gt; or single quotes &lt;strong&gt;'[String]'&lt;/strong&gt; &lt;em&gt;(single quotes seem to be the most common convention)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;To interpolate something into a String, you prefix it with a dollar sign &lt;strong&gt;$&lt;/strong&gt;. If you are interpolating an expression, you will wrap the expression inside of curly braces which follow the dollar sign &lt;strong&gt;${[expression]}&lt;/strong&gt;.&lt;br&gt;
&lt;em&gt;You may always use the curly brace expression, but conventionally it is only used when required.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'Colton'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;lastName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'Ehrman'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;fullName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="si"&gt;$firstName&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="si"&gt;$lastName&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// interpolated value&lt;/span&gt;
&lt;span class="c1"&gt;// fullName will be the String 'Colton Ehrman'&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;yearBorn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1995&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;currentYear&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2020&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;ageText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'I am &lt;/span&gt;&lt;span class="si"&gt;${currentYear - yearBorn}&lt;/span&gt;&lt;span class="s"&gt; years old!'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// interpolating an expression inside of a String&lt;/span&gt;
&lt;span class="c1"&gt;// ageText will be 'I am 25 years old!'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h5&gt;
  
  
  Weird interpolation example's to watch out for &lt;a&gt;&lt;/a&gt;
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'Colton'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// trying to interpolate Object property into string&lt;/span&gt;
&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;weirdResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'My name is &lt;/span&gt;&lt;span class="si"&gt;$firstName&lt;/span&gt;&lt;span class="s"&gt;.length characters.'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// weirdResult will be 'My name is Colton.length characters.'&lt;/span&gt;

&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;properResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'My name is &lt;/span&gt;&lt;span class="si"&gt;${firstName.length}&lt;/span&gt;&lt;span class="s"&gt; characters.'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// properResult == 'My name is 6 characters long.'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Without the curly braces in the interpolation, Dart will only interpolate up to a valid variable name, anything else that follows will be treated as a String.&lt;/p&gt;

&lt;h4&gt;
  
  
  Creating a Class &lt;a&gt;&lt;/a&gt;
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="c1"&gt;// class definition&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="err"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;class&lt;/span&gt; &lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// body of class&lt;/span&gt;
  &lt;span class="c1"&gt;// the class can consist of these things&lt;/span&gt;
  &lt;span class="c1"&gt;// the order does not matter&lt;/span&gt;
  &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;constructors&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
  &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;properties&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
  &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;methods&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Example&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// property&lt;/span&gt;
  &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;lastName&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// property&lt;/span&gt;

  &lt;span class="c1"&gt;// method&lt;/span&gt;
  &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;fullName&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="si"&gt;$firstName&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="si"&gt;$lastName&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the example, we are defining a class named &lt;strong&gt;Person&lt;/strong&gt;, which consists of two properties, &lt;strong&gt;firstName&lt;/strong&gt; and &lt;strong&gt;lastName&lt;/strong&gt;, and a single method named &lt;strong&gt;fullName&lt;/strong&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  Creating an Object &lt;a&gt;&lt;/a&gt;
&lt;/h5&gt;

&lt;p&gt;With our previous Class &lt;strong&gt;Person&lt;/strong&gt;, we will create some Objects.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="c1"&gt;// declare variable of [Type] Person&lt;/span&gt;
&lt;span class="n"&gt;Person&lt;/span&gt; &lt;span class="n"&gt;me&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// assign new instance of Person to variable&lt;/span&gt;
&lt;span class="n"&gt;me&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Person&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// assign values to object properties&lt;/span&gt;
&lt;span class="n"&gt;me&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'Colton'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;me&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;lastName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'Ehrman'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// calling object methods&lt;/span&gt;
&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;myFullName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;me&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fullName&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Error!&lt;/span&gt;
&lt;span class="n"&gt;me&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;eyeColor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'brown'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// the Person class does not have a property of 'eyeColor'&lt;/span&gt;
&lt;span class="c1"&gt;// so this will cause an error in Dart&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can create new &lt;strong&gt;instances&lt;/strong&gt; of a Class by calling it like a function with the &lt;strong&gt;new&lt;/strong&gt; keyword in front of it (&lt;em&gt;new [Class name]()&lt;/em&gt; | &lt;strong&gt;new Person()&lt;/strong&gt;).&lt;br&gt;
&lt;em&gt;The &lt;strong&gt;new&lt;/strong&gt; keyword is actually optional and you can create an instance of a Class without it.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To access properties and methods of an object you use &lt;strong&gt;dot-notation&lt;/strong&gt; (&lt;em&gt;[object].[property|method]&lt;/em&gt;).&lt;/p&gt;
&lt;h4&gt;
  
  
  Class Constructors &lt;a&gt;&lt;/a&gt;
&lt;/h4&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// constructor&lt;/span&gt;
  &lt;span class="c1"&gt;// must named the same name as Class name&lt;/span&gt;
  &lt;span class="c1"&gt;// can have any number of parameters&lt;/span&gt;
  &lt;span class="n"&gt;Person&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;lastName&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// assigning property&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;lastName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;lastName&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// assigning property&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;lastName&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;A Class's constructor must be named the same as the Class's name. If the constructor takes parameters that have the same name as properties of the class, you must differentiate them by using the &lt;strong&gt;this&lt;/strong&gt; keyword in front of the properties of the Class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;this&lt;/strong&gt; keyword is not required when using properties/methods of a Class, unless in a context where the reference would be ambiguous.&lt;/p&gt;

&lt;p&gt;With a constructor now, when you instantiate Objects of a Class, the appropriate constructor will be called.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;Person&lt;/span&gt; &lt;span class="n"&gt;me&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// will call the constructor that we defined earlier&lt;/span&gt;
&lt;span class="n"&gt;me&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Person&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Colton'&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'Ehrman'&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// the 'new' keyword is not required&lt;/span&gt;
&lt;span class="c1"&gt;// 'me' Object will be created with&lt;/span&gt;
&lt;span class="c1"&gt;// 'firstName' and 'lastName' properties already set&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h5&gt;
  
  
  Special Constructor &lt;a&gt;&lt;/a&gt;
&lt;/h5&gt;

&lt;p&gt;In Dart, you can easily create common constructors, like the one we made earlier, using a special syntax.&lt;/p&gt;

&lt;p&gt;Let's take the previous constructor and simplify it using the new syntax.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// special constructor&lt;/span&gt;
  &lt;span class="c1"&gt;// parameters must be prefixed with 'this.'&lt;/span&gt;
  &lt;span class="c1"&gt;// parameters must match class properties&lt;/span&gt;
  &lt;span class="n"&gt;Person&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;lastName&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

  &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;lastName&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;With this new syntax, Dart will &lt;em&gt;automagically&lt;/em&gt; understand what you want and do it for you. It is the same as the previous constructor we made.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Just remember: each parameter must be prefixed with &lt;strong&gt;this.&lt;/strong&gt; AND &lt;strong&gt;match&lt;/strong&gt; a property that exists within the Class&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Flutter
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Widgets &lt;a&gt;&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;Widgets are the building blocks of flutter. Practically everything you do will be in the form of a Widget. The flutter framework provides tons of built-in &lt;a href="https://flutter.dev/docs/development/ui/widgets"&gt;Widgets&lt;/a&gt; to get started with. You will use these along with building your own custom Widgets.&lt;/p&gt;

&lt;h4&gt;
  
  
  Common Widgets &lt;a&gt;&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;As you start building with the Flutter framework, you will become accustomed to common Widgets that you will use.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Such as&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://api.flutter.dev/flutter/material/MaterialApp-class.html"&gt;MaterialApp&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://api.flutter.dev/flutter/material/Scaffold-class.html"&gt;Scaffold&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://api.flutter.dev/flutter/widgets/Container-class.html"&gt;Container&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://api.flutter.dev/flutter/widgets/Column-class.html"&gt;Column&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://api.flutter.dev/flutter/widgets/Row-class.html"&gt;Row&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://api.flutter.dev/flutter/widgets/ListView-class.html"&gt;ListView&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://api.flutter.dev/flutter/widgets/Text-class.html"&gt;Text&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are just a few of the most common Widgets, there are many more that you will see as well.&lt;/p&gt;

&lt;h4&gt;
  
  
  ListView &lt;a&gt;&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;ListView is a common Widget used when building a list of Widgets in your App, that the user can scroll through. Think, social media feeds, probably the most common ListView we are familiar with.&lt;/p&gt;

&lt;p&gt;You typically will be creating a custom Widget that utilizes the &lt;code&gt;ListView&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;There are two common constructors that you can use when building a ListView. One is the build all at once constructor (&lt;a href="https://api.flutter.dev/flutter/widgets/ListView/ListView.html"&gt;&lt;code&gt;ListView()&lt;/code&gt;&lt;/a&gt;) and the other building on-demand constructor (&lt;a href="https://api.flutter.dev/flutter/widgets/ListView/ListView.builder.html"&gt;&lt;code&gt;ListView.builder()&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;You will want to decide which one best suits your needs. If you know the list is going to contain a lot of elements and potentially take a while to build all at once, you probably want to use the &lt;code&gt;ListView.builder()&lt;/code&gt;. Otherwise, the main constructor should do the trick.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Just keep in mind what kind of list you are trying to build and how the ListView will affect the performance of your app.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;To Be Continued...&lt;/em&gt;&lt;/p&gt;

</description>
      <category>learning</category>
      <category>flutter</category>
      <category>dart</category>
    </item>
    <item>
      <title>Guidance: Plan for Life</title>
      <dc:creator>Colton Ehrman</dc:creator>
      <pubDate>Thu, 26 Mar 2020 03:17:13 +0000</pubDate>
      <link>https://dev.to/coltonehrman/guidance-plan-for-life-2pkh</link>
      <guid>https://dev.to/coltonehrman/guidance-plan-for-life-2pkh</guid>
      <description>&lt;p&gt;This will guide you towards setting up an eternal &lt;em&gt;(lasting or existing forever; without end or beginning)&lt;/em&gt; plan for your life.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tools:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://todoist.com/r/colton_ehrman_xzlapc"&gt;Todist&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sections
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;What To-Do NOW?&lt;/li&gt;
&lt;li&gt;Create A Blueprint&lt;/li&gt;
&lt;li&gt;Create Weekly To-Do List&lt;/li&gt;
&lt;li&gt;Create Today's To-Do List&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What to do NOW? &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;I am adding this section based on the fact that I run into this problem a lot of times. Where I am working on something and asking myself, &lt;em&gt;"Should I be working on this right now, or maybe something else?"&lt;/em&gt;, or when I am questioning what I should do at this moment &lt;em&gt;(usually after I finished doing something pretty productive)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;It seems that this may be my biggest problem and most likely the reason that pushed me into writing this whole article and doing what I am doing today.&lt;/p&gt;

&lt;p&gt;So, let me think this out for a minute. I have trouble coming up with what "direction" to go in. My mind is cluttered with all these ideas and possibilities of what to do next. My first step to solving this was to write it all down with the idea of getting it out of my head and onto something that I can plainly visualize and hopefully better sort/organize.&lt;/p&gt;

&lt;p&gt;I feel that this is a great first step in the &lt;em&gt;right&lt;/em&gt; direction. Now I need to focus on untangling this mess that I just threw up, and figure out what is worth keeping and what to throw away.&lt;/p&gt;

&lt;p&gt;Being somewhat of a hoarder &lt;em&gt;(along the lines of, "I don't know if I will need this later, so I will keep it for now")&lt;/em&gt; I will probably save the task of weeding through it for later. Let's just focus on finding the &lt;em&gt;right&lt;/em&gt; direction for now.&lt;/p&gt;

&lt;p&gt;I have everything &lt;em&gt;(mostly)&lt;/em&gt; that I am currently thinking out of my head and down on something I can look at and visualize. Now, I am going to pick the first thing that excites me the most, the thing that I can see myself doing for a long period of time and not worrying about getting tired of and dropping all the sudden. Because &lt;strong&gt;another problem&lt;/strong&gt; I have is sticking to a specific goal instead of juggling a bunch of things around and usually dropping them all one-by-one.&lt;/p&gt;

&lt;p&gt;Now that I have finally &lt;strong&gt;picked one thing&lt;/strong&gt;, I am going to focus on this singular idea for the most part of my days. Starting &lt;strong&gt;&lt;em&gt;NOW&lt;/em&gt;&lt;/strong&gt;, I will use this idea as the sort of blueprint to start up my day. &lt;em&gt;How can I break down this idea into specific tasks and short-term goals?&lt;/em&gt; This is the question I will ask myself.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;To better give some practical advice for this article, I will show you exactly what I am using to follow along with this "junk-of-information".&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I &lt;strong&gt;picked&lt;/strong&gt; the idea of &lt;em&gt;learning flutter&lt;/em&gt; out of the other ideas I had spit out from my head, as my focus.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--51Iu7hPL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/pws0lXr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--51Iu7hPL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/pws0lXr.png" alt="List of ideas"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you pick something that is making you think "I don't know if I will be able to stick with this for very long, or has you feeling at unease", then you probably didn't pick the &lt;strong&gt;right&lt;/strong&gt; thing. Although I will say, the thing I picked I am feeling a little anxious about, but it is not a concern for me at this moment since I am doing this all as an experiment and learning process&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now&lt;/strong&gt;, let me take this idea, and start devising specific tasks and goals that revolve around it for my everyday to-do lists.&lt;/p&gt;

&lt;p&gt;First, I am going to put together a basic to-do list for my day tomorrow, then I will be able to insert my specific tasks into my day.&lt;/p&gt;

&lt;p&gt;Here is my basic list, with typical tasks that I do every day. I put this together using the blueprint section.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9BEPnjR5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/PwDBTuJ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9BEPnjR5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/PwDBTuJ.png" alt="Basic to-do list"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This gives me something to start with and an idea of how my day will look so far. Now I can begin incorporating the other tasks into this list.&lt;/p&gt;

&lt;p&gt;My over-arching focus is &lt;strong&gt;learning flutter&lt;/strong&gt;, so I am going to come up with things to do that embrace this idea. To start, I want to reflect on my current status, such as what I have at my disposal.&lt;/p&gt;

&lt;p&gt;Luckily, I recently purchased two courses that &lt;em&gt;teach flutter&lt;/em&gt;. Also, I happen to be working on a couple of projects with &lt;em&gt;some other people&lt;/em&gt; which involve me building a flutter app.&lt;/p&gt;

&lt;p&gt;So, at this point it appears that I have the resources necessary to begin putting together specific tasks related to &lt;strong&gt;learning flutter&lt;/strong&gt;. Let me go ahead and add some specific tasks into my list &lt;strong&gt;NOW&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Here are the two &lt;strong&gt;general&lt;/strong&gt; tasks I came up with.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3WWqJejo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/I7uj4ix.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3WWqJejo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/I7uj4ix.png" alt="Two general tasks"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I decided to pick the Udemy course as my focus right now since it doesn't require other people's involvement and I can work on it at my own pace.&lt;/p&gt;

&lt;p&gt;Also, I know where I am currently at in the course is building a flutter app, so I wanted to add a specific task for that as well. Even though these two tasks are so related, they help define my &lt;em&gt;actions&lt;/em&gt; for the day, which is what I am trying to do.&lt;/p&gt;

&lt;p&gt;This is just the start, I &lt;strong&gt;now&lt;/strong&gt; need to break these tasks up into even more specific &lt;em&gt;actions&lt;/em&gt; that I can take.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Here is what I came up with&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8BzBZFFU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/jF7LiP2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8BzBZFFU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/jF7LiP2.png" alt="Added specific tasks"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Not going to lie, this part was difficult for me, and I am still not fully satisfied with it. Nonetheless, it is a starting point and will do for now.&lt;/p&gt;

&lt;p&gt;I have broken up the general tasks into more specific &lt;em&gt;actions&lt;/em&gt;. Tomorrow, I will be able to go through my task list with little to no thinking involved, just &lt;strong&gt;taking action&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Also, I have added some comments to each task, forcing myself to explain why I am doing this, and the reasoning involved &lt;em&gt;(just in case I need a reminder)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vqwFj84P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/QZo2LcV.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vqwFj84P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/QZo2LcV.png" alt="Task comment"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I feel satisfied with my current progression at this point, and believe my process will only get better over time and practice. I foresee myself running into some issues tomorrow, with some specific tasks I have put in the list, but plan on tackling that when the time comes.&lt;/p&gt;

&lt;p&gt;For now, I will focus on the end goal. Whenever I encounter a problem, I plan on documenting it and going over a possible solution.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;To be continued...&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Create A Blueprint &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Put together a general to-do list blueprint with things that you need to do repeatedly&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This one is pretty obvious, but here are some ideas and tips to help you -  this blueprint can apply to daily to-dos, weekly, monthly, etc.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;How a blueprint list may look&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9BEPnjR5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/PwDBTuJ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9BEPnjR5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/PwDBTuJ.png" alt="Basic to-do list"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is something you always end up needing to do? &lt;em&gt;Wake up, shower, eat, sleep, pay bills, etc.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Try to add tasks that you &lt;em&gt;want&lt;/em&gt; to start doing into your blueprint. &lt;em&gt;This will force you to build better habits&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Set times and reminders for tasks to get into a routine.&lt;/li&gt;
&lt;li&gt;Play around with different times to see what works best for you. &lt;em&gt;Maybe you study better around bedtime instead of the morning&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;No task is too small to add to the list. &lt;em&gt;Pretend you are a computer and you are writing out a daily algorithm for your body to follow and make it through the day, every second counts&lt;/em&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Create Weekly To-Do List &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Let's create a weekly to-do list.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I would recommend setting up a blueprint that you can use.&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Ask yourself - &lt;em&gt;What is something I end up doing every week?&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Are you working on something at the moment? &lt;em&gt;Break up that project into specific daily tasks, which can then be more detailed the day of or before. The idea is to start breaking up the project at a high level&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Have something you've been meaning to get done? &lt;em&gt;Look through your current daily to-dos, and pick one that seems pretty open to add that task to&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;When making up a weekly to-do, it is also a good idea to start looking at upcoming events/plans and organizing them better for your schedule.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Create Today's To-Do List &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Let's create today's to-do list, or preferably tomorrow's if you want to stay ahead of the game!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I would recommend setting up a daily to-do list blueprint that you can use.&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Ask yourself - &lt;em&gt;What do I need to get done this day?&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Are you working on something at the moment? &lt;em&gt;Start breaking up that project into small tasks, don't worry about overloading your day, just write it down so it can get done&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;What have you been thinking about lately? &lt;em&gt;I really want to clean my room. I wish my truck was clean. Ughh, when will I finally make time to read that book&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Is there anything you wish was better organized in your life? &lt;em&gt;Clean up and organize your cluttered phone screen of apps. Go through your digital files and clean out / organize them&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Are there any activities/habits you should remove from your life? &lt;em&gt;Identify and replace those with literally anything that is better for you&lt;/em&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Goals:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Stop asking yourself what to do every day&lt;/li&gt;
&lt;li&gt;Have a concrete guideline of what to do now&lt;/li&gt;
&lt;li&gt;Stop questioning what's next or looking ahead&lt;/li&gt;
&lt;li&gt;Focus on the important things in life&lt;/li&gt;
&lt;li&gt;Declutter your life&lt;/li&gt;
&lt;li&gt;Attain &lt;em&gt;(succeed in achieving something that one desires and has worked for)&lt;/em&gt; a clear mind&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
  </channel>
</rss>
