<?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: emjaycodes</title>
    <description>The latest articles on DEV Community by emjaycodes (@emjaycodes).</description>
    <link>https://dev.to/emjaycodes</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%2F883565%2Fd6748777-15cf-48a8-816f-fe13e1c4894a.jpg</url>
      <title>DEV Community: emjaycodes</title>
      <link>https://dev.to/emjaycodes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/emjaycodes"/>
    <language>en</language>
    <item>
      <title>Pokémon Card App: Exploring REST API in Dart and Flutter</title>
      <dc:creator>emjaycodes</dc:creator>
      <pubDate>Thu, 10 Aug 2023 10:27:15 +0000</pubDate>
      <link>https://dev.to/emjaycodes/pokemon-card-app-exploring-rest-api-in-dart-and-flutter-1h0j</link>
      <guid>https://dev.to/emjaycodes/pokemon-card-app-exploring-rest-api-in-dart-and-flutter-1h0j</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;The Pokémon universe has captivated millions of fans worldwide, and the thrill of collecting Pokémon cards is unmatched. What if you could bring that excitement to the digital realm?&lt;/p&gt;

&lt;p&gt;In this article, we will embark on an exciting journey to create a Pokémon Card app using Dart and Flutter. Our primary focus will be leveraging REST APIs to fetch Pokémon data and dynamically generate Pokémon cards. Along the way, we'll delve into the fundamentals of working with REST APIs, making network requests, and handling data in a Flutter application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding REST APIs
&lt;/h2&gt;

&lt;p&gt;REST APIs have emerged as a cornerstone for creating dynamic and interconnected applications in app development. REST (Representational State Transfer) APIs provide a standardized and platform-independent way for applications to communicate and exchange data over the Internet. They enable developers to seamlessly integrate external systems and access different data sources and functionalities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Fundamental knowledge of Flutter and Dart&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An emulator or a smartphone for debugging&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Set up a Flutter Project
&lt;/h2&gt;

&lt;p&gt;Before we begin, make sure you have the following installed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Flutter SDK&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Dart SDK&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Code editor (e.g., Visual Studio Code, Android Studio)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  A Flowchart of the Application
&lt;/h3&gt;

&lt;p&gt;Let’s get the rundown on how the app is going to work. Once you launch the app, you will see a button that says generate, When you tap on the button, you will see a Pokemon character, and if that doesn’t happen, you’ll see a dialog box telling you why it didn’t work and an action button.&lt;/p&gt;

&lt;p&gt;Let's visualize the flow of actions using a flowchart. Take a look at the diagram to get a better understanding.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fxt4q12brtaqbcsong2ej.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fxt4q12brtaqbcsong2ej.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;fig 1. A Flowchart of the Application&lt;/p&gt;

&lt;h3&gt;
  
  
  Create the Pokemon Card Application
&lt;/h3&gt;

&lt;p&gt;To create the Pokemon card application, we'll follow these steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Set up a new Flutter project:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open your terminal or command prompt.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run the command:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;flutter&lt;/span&gt; &lt;span class="n"&gt;create&lt;/span&gt; &lt;span class="n"&gt;pokemon_card_app&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Navigate to the project directory:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;cd&lt;/span&gt; &lt;span class="n"&gt;pokemon_card_app&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Open the project in your preferred code editor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add dependencies:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open the pubspec.yaml file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add the following dependencies under the dependencies section:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="nl"&gt;Dependencies:&lt;/span&gt;

&lt;span class="nl"&gt;flutter:&lt;/span&gt; &lt;span class="nl"&gt;sdk:&lt;/span&gt;
&lt;span class="nl"&gt;http:&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="mf"&gt;0.13&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="n"&gt;flutter&lt;/span&gt; &lt;span class="nl"&gt;flip_card:&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="nl"&gt;google_fonts:&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="mf"&gt;2.1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="nl"&gt;flutter_spinkit:&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="mf"&gt;5.1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save the file and run flutter pub get in the terminal to fetch the dependencies.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Make HTTP Requests with Dart
&lt;/h2&gt;

&lt;p&gt;An Overview of the HTTP package in Dart&lt;/p&gt;

&lt;p&gt;The HTTP package in Dart provides a straightforward and efficient way to make HTTP requests and handle responses in Dart applications. It simplifies interacting with APIs and retrieving data from external sources.&lt;/p&gt;

&lt;p&gt;Dart's HTTP package offers classes and methods that allow developers to send HTTP requests and handle responses.&lt;/p&gt;

&lt;p&gt;It supports various HTTP methods such as GET, POST, PUT, DELETE, etc., and provides functionalities to set headers, pass query parameters, and handle cookies. The package also supports working with JSON, allowing developers to quickly parse and serialize JSON data.&lt;/p&gt;

&lt;p&gt;In this article, you will only be using the GET methods to retrieve data from the Pokemon API&lt;/p&gt;

&lt;h3&gt;
  
  
  Implement Functions to handle API Requests and Responses
&lt;/h3&gt;

&lt;p&gt;To demonstrate the implementation of functions for handling API requests and responses, we'll use the HTTP package in Dart. First, make sure to include the HTTP package in your project by adding the following import statement to your Dart file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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: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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Make a GET request
&lt;/h3&gt;

&lt;p&gt;To make a GET request to an API endpoint, you can use the get function provided by the HTTP package. Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;Future&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;fetchData&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kd"&gt;async&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;Uri&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'https://api.example.com/data'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&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="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;statusCode&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;// Successful response&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// Handle the retrieved data&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;// Error handling&lt;/span&gt;
&lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Request failed with status: &lt;/span&gt;&lt;span class="si"&gt;${response.statusCode}&lt;/span&gt;&lt;span class="s"&gt;.'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Design the Pokémon Card UI
&lt;/h2&gt;

&lt;p&gt;Designing the layout and structure of a Pokémon card is crucial to creating an appealing and user-friendly UI. The card serves as a visual representation of the Pokémon and provides essential information to the user. Let's discuss the planning of the layout and structure and how to utilize Flutter widgets to create a visually appealing and interactive Pokémon card.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layout and Structure of the Pokémon card
&lt;/h3&gt;

&lt;p&gt;The layout and structure of the Pokémon card will consist of a "&lt;strong&gt;Column&lt;/strong&gt;" with a "&lt;strong&gt;FlipCard"&lt;/strong&gt; widget as the main component. The card's front side displays the Pokémon's "&lt;strong&gt;sprite&lt;/strong&gt;" and "&lt;strong&gt;name&lt;/strong&gt;", while the back side will show the Pokémon's "&lt;strong&gt;ID&lt;/strong&gt;", "&lt;strong&gt;abilities&lt;/strong&gt;", "&lt;strong&gt;type&lt;/strong&gt;", "&lt;strong&gt;height&lt;/strong&gt;", and "&lt;strong&gt;weight&lt;/strong&gt;". The design utilizes "&lt;strong&gt;Container&lt;/strong&gt;", "&lt;strong&gt;Column&lt;/strong&gt;", "&lt;strong&gt;SizedBox&lt;/strong&gt;", "&lt;strong&gt;Text&lt;/strong&gt;", "&lt;strong&gt;Image&lt;/strong&gt;", "&lt;strong&gt;CircularProgressIndicator&lt;/strong&gt;", and custom widgets to create the Pokémon card.&lt;/p&gt;

&lt;p&gt;Now let's dive into the code for the Pokemon card:&lt;/p&gt;

&lt;p&gt;Firstly Open the lib directory and create a new file named "&lt;strong&gt;flipping_card.dart"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Then in this file, we'll import the following:&lt;/p&gt;

&lt;p&gt;After importing, create a stateless widget called "&lt;strong&gt;FlippingPokemonCard".&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;FlippingPokemonCard&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatelessWidget&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;sprites&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;abilities&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;FlippingPokemonCard&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kd"&gt;required&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;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kd"&gt;required&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;height&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kd"&gt;required&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;weight&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kd"&gt;required&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="p"&gt;,&lt;/span&gt;
    &lt;span class="kd"&gt;required&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;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kd"&gt;required&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;sprites&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kd"&gt;required&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;abilities&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&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="p"&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="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;mainAxisAlignment:&lt;/span&gt; &lt;span class="n"&gt;MainAxisAlignment&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;center&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;children:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="p"&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="p"&gt;(&lt;/span&gt;
              &lt;span class="nl"&gt;height:&lt;/span&gt; &lt;span class="n"&gt;MediaQuery&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;height&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="nl"&gt;width:&lt;/span&gt; &lt;span class="n"&gt;MediaQuery&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;width&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;FlipCard&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                  &lt;span class="nl"&gt;front:&lt;/span&gt; &lt;span class="n"&gt;Container&lt;/span&gt;&lt;span class="p"&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="p"&gt;(&lt;/span&gt;
                      &lt;span class="nl"&gt;color:&lt;/span&gt; &lt;span class="n"&gt;Colors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;amberAccent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                      &lt;span class="nl"&gt;borderRadius:&lt;/span&gt; &lt;span class="n"&gt;BorderRadius&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;circular&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
                      &lt;span class="nl"&gt;boxShadow:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
                        &lt;span class="n"&gt;BoxShadow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                            &lt;span class="nl"&gt;color:&lt;/span&gt; &lt;span class="n"&gt;Colors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;black&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                            &lt;span class="nl"&gt;offset:&lt;/span&gt; &lt;span class="n"&gt;Offset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;3.0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
                            &lt;span class="nl"&gt;blurRadius:&lt;/span&gt; &lt;span class="mf"&gt;9.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                            &lt;span class="nl"&gt;spreadRadius:&lt;/span&gt; &lt;span class="mf"&gt;2.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                      &lt;span class="p"&gt;],&lt;/span&gt;
                    &lt;span class="p"&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="p"&gt;(&lt;/span&gt;
                      &lt;span class="nl"&gt;children:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
                        &lt;span class="n"&gt;SizedBox&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                          &lt;span class="nl"&gt;height:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="p"&gt;),&lt;/span&gt;
                        &lt;span class="n"&gt;Expanded&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                          &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Image&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;network&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sprites&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                              &lt;span class="nl"&gt;loadingBuilder:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;child&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;loadingProgress&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;loadingProgress&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                              &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;child&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                            &lt;span class="p"&gt;}&lt;/span&gt;
                            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;CircularProgressIndicator&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
                          &lt;span class="p"&gt;}),&lt;/span&gt;
                        &lt;span class="p"&gt;),&lt;/span&gt;
                        &lt;span class="n"&gt;SizedBox&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;height:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
                        &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                          &lt;span class="s"&gt;'Name: &lt;/span&gt;&lt;span class="si"&gt;$name&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="p"&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="p"&gt;(&lt;/span&gt;
                            &lt;span class="nl"&gt;fontWeight:&lt;/span&gt; &lt;span class="n"&gt;FontWeight&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                            &lt;span class="nl"&gt;fontSize:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                          &lt;span class="p"&gt;),&lt;/span&gt;
                        &lt;span class="p"&gt;),&lt;/span&gt;
                      &lt;span class="p"&gt;],&lt;/span&gt;
                    &lt;span class="p"&gt;),&lt;/span&gt;
                  &lt;span class="p"&gt;),&lt;/span&gt;
                  &lt;span class="nl"&gt;back:&lt;/span&gt; &lt;span class="n"&gt;LayoutBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;builder:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;contraints&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&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="p"&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="p"&gt;(&lt;/span&gt;
                        &lt;span class="nl"&gt;boxShadow:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
                          &lt;span class="n"&gt;BoxShadow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                              &lt;span class="nl"&gt;color:&lt;/span&gt; &lt;span class="n"&gt;Colors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;black&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                              &lt;span class="nl"&gt;offset:&lt;/span&gt; &lt;span class="n"&gt;Offset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;5.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;5.0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
                              &lt;span class="nl"&gt;blurRadius:&lt;/span&gt; &lt;span class="mf"&gt;10.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                              &lt;span class="nl"&gt;spreadRadius:&lt;/span&gt; &lt;span class="mf"&gt;2.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                        &lt;span class="p"&gt;],&lt;/span&gt;
                        &lt;span class="nl"&gt;color:&lt;/span&gt; &lt;span class="n"&gt;Colors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;yellow&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="nl"&gt;borderRadius:&lt;/span&gt; &lt;span class="n"&gt;BorderRadius&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;circular&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
                      &lt;span class="p"&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="p"&gt;(&lt;/span&gt;
                        &lt;span class="nl"&gt;crossAxisAlignment:&lt;/span&gt; &lt;span class="n"&gt;CrossAxisAlignment&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;center&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="nl"&gt;mainAxisAlignment:&lt;/span&gt; &lt;span class="n"&gt;MainAxisAlignment&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="nl"&gt;children:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
                          &lt;span class="n"&gt;SizedBox&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                            &lt;span class="nl"&gt;height:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                          &lt;span class="p"&gt;),&lt;/span&gt;
                          &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                            &lt;span class="s"&gt;'ID: &lt;/span&gt;&lt;span class="si"&gt;${id.toString()}&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="p"&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="p"&gt;(&lt;/span&gt;
                              &lt;span class="nl"&gt;fontWeight:&lt;/span&gt; &lt;span class="n"&gt;FontWeight&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                              &lt;span class="nl"&gt;fontSize:&lt;/span&gt; &lt;span class="mi"&gt;59&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                            &lt;span class="p"&gt;),&lt;/span&gt;
                          &lt;span class="p"&gt;),&lt;/span&gt;
                          &lt;span class="n"&gt;SizedBox&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                            &lt;span class="nl"&gt;height:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                          &lt;span class="p"&gt;),&lt;/span&gt;
                          &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                            &lt;span class="s"&gt;'Name: &lt;/span&gt;&lt;span class="si"&gt;$name&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="p"&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="p"&gt;(&lt;/span&gt;
                              &lt;span class="nl"&gt;fontWeight:&lt;/span&gt; &lt;span class="n"&gt;FontWeight&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                              &lt;span class="nl"&gt;fontSize:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                            &lt;span class="p"&gt;),&lt;/span&gt;
                          &lt;span class="p"&gt;),&lt;/span&gt;
                          &lt;span class="n"&gt;SizedBox&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                            &lt;span class="nl"&gt;height:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                          &lt;span class="p"&gt;),&lt;/span&gt;
                          &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;contraints&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;maxHeight&lt;/span&gt; &lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                          &lt;span class="n"&gt;Expanded&lt;/span&gt;&lt;span class="p"&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="p"&gt;(&lt;/span&gt;
                              &lt;span class="s"&gt;'Ability: &lt;/span&gt;&lt;span class="si"&gt;$abilities&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="p"&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="p"&gt;(&lt;/span&gt;
                                &lt;span class="nl"&gt;fontWeight:&lt;/span&gt; &lt;span class="n"&gt;FontWeight&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                &lt;span class="nl"&gt;fontSize:&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                              &lt;span class="p"&gt;),&lt;/span&gt;
                            &lt;span class="p"&gt;),&lt;/span&gt;
                          &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                              &lt;span class="s"&gt;'Ability: &lt;/span&gt;&lt;span class="si"&gt;$abilities&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="p"&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="p"&gt;(&lt;/span&gt;
                                &lt;span class="nl"&gt;fontWeight:&lt;/span&gt; &lt;span class="n"&gt;FontWeight&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                &lt;span class="nl"&gt;fontSize:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                              &lt;span class="p"&gt;),&lt;/span&gt;
                            &lt;span class="p"&gt;),&lt;/span&gt;

                          &lt;span class="n"&gt;SizedBox&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                            &lt;span class="nl"&gt;height:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                          &lt;span class="p"&gt;),&lt;/span&gt;
                          &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                            &lt;span class="s"&gt;'Type: &lt;/span&gt;&lt;span class="si"&gt;$type&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="p"&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="p"&gt;(&lt;/span&gt;
                              &lt;span class="nl"&gt;fontWeight:&lt;/span&gt; &lt;span class="n"&gt;FontWeight&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                              &lt;span class="nl"&gt;fontSize:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                            &lt;span class="p"&gt;),&lt;/span&gt;
                          &lt;span class="p"&gt;),&lt;/span&gt;
                          &lt;span class="n"&gt;SizedBox&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                            &lt;span class="nl"&gt;height:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                          &lt;span class="p"&gt;),&lt;/span&gt;
                          &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                            &lt;span class="s"&gt;'Height: &lt;/span&gt;&lt;span class="si"&gt;${height.toString()}&lt;/span&gt;&lt;span class="s"&gt; mm'&lt;/span&gt;&lt;span class="p"&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="p"&gt;(&lt;/span&gt;
                              &lt;span class="nl"&gt;fontWeight:&lt;/span&gt; &lt;span class="n"&gt;FontWeight&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                              &lt;span class="nl"&gt;fontSize:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                            &lt;span class="p"&gt;),&lt;/span&gt;
                          &lt;span class="p"&gt;),&lt;/span&gt;
                          &lt;span class="n"&gt;SizedBox&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                            &lt;span class="nl"&gt;height:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                          &lt;span class="p"&gt;),&lt;/span&gt;
                          &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                            &lt;span class="s"&gt;' Weight: &lt;/span&gt;&lt;span class="si"&gt;${weight.toString()}&lt;/span&gt;&lt;span class="s"&gt; LBS'&lt;/span&gt;&lt;span class="p"&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="p"&gt;(&lt;/span&gt;
                              &lt;span class="nl"&gt;fontWeight:&lt;/span&gt; &lt;span class="n"&gt;FontWeight&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                              &lt;span class="nl"&gt;fontSize:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                            &lt;span class="p"&gt;),&lt;/span&gt;
                          &lt;span class="p"&gt;),&lt;/span&gt;
                        &lt;span class="p"&gt;],&lt;/span&gt;
                      &lt;span class="p"&gt;),&lt;/span&gt;
                    &lt;span class="p"&gt;);&lt;/span&gt;
                  &lt;span class="p"&gt;},),),),&lt;/span&gt;
        &lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="n"&gt;SizedBox&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
          &lt;span class="nl"&gt;height:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a lot of code, so you can take a minute to go through it and understand what is happening, but here is a breakdown of the layout and structure of the Pokémon card:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The "&lt;strong&gt;FlippingPokemonCard"&lt;/strong&gt; widget extends "&lt;strong&gt;StatelessWidget&lt;/strong&gt;", indicating it won't have any mutable state.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The widget's constructor takes several required parameters, such as type, height, weight, id, name, sprites, and abilities. These parameters represent the information about a specific Pokémon that will be displayed on the card.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inside the "&lt;strong&gt;build()"&lt;/strong&gt; method, the widget is structured as a "&lt;strong&gt;Column"&lt;/strong&gt; widget. This allows us to vertically arrange the components of the card.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The card is implemented using the FlipCard widget from the "&lt;strong&gt;flip_card&lt;/strong&gt;" package. It takes two child widgets: the card's front and back. The card flips horizontally to reveal the back when tapped.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The front side of the card is wrapped inside a "&lt;strong&gt;Container"&lt;/strong&gt; widget. It has a decoration property that defines the appearance of the card. It includes a background color, border radius, and a shadow effect.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inside the front side of the card, there is a "&lt;strong&gt;Column&lt;/strong&gt;" widget containing the following components:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A "&lt;strong&gt;SizedBox"&lt;/strong&gt; for adding some vertical spacing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An "&lt;strong&gt;Image"&lt;/strong&gt; widget to display the Pokémon's sprite. It loads the image from the given sprites URL. While the image is loading, a "&lt;strong&gt;CircularProgressIndicato&lt;/strong&gt;r" is shown.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A "&lt;strong&gt;Text&lt;/strong&gt;" widget displaying the Pokémon's name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The back side of the card is implemented using the &lt;strong&gt;"LayoutBuilder"&lt;/strong&gt; widget. It allows us to adjust the layout based on the available space.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inside the "&lt;strong&gt;LayoutBuilder"&lt;/strong&gt; is a &lt;strong&gt;"Container"&lt;/strong&gt; widget with similar decoration to the front side of the card. It includes a background color, border radius, and shadow effect.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inside the back side of the card, there is a "&lt;strong&gt;Column&lt;/strong&gt;" widget containing the following components:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A conditional rendering of the ability Text widget. If the card's height exceeds 300, the ability text is wrapped inside an "&lt;strong&gt;Expanded"&lt;/strong&gt; widget to allow it to take up the remaining vertical space. Otherwise, it is displayed without the "&lt;strong&gt;Expanded"&lt;/strong&gt; widget.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;"&lt;strong&gt;Text&lt;/strong&gt;" widgets display the Pokémon's name, ID type, height, and weight.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Create a Model Class to parse the JSON.
&lt;/h2&gt;

&lt;p&gt;Create a folder inside the lib folder called models; then, in this models folder, Create a file called "&lt;a href="http://pokemon.data" rel="noopener noreferrer"&gt;pokemon.data&lt;/a&gt;"; this is the file where you will write the code for the Dart Object;&lt;/p&gt;

&lt;p&gt;The model is a class that holds the data gotten from the API, like the name, height, etc., and this class will house a function to convert the JSON data to a Dart object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;PokemonInfo&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;type&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;weight&lt;/span&gt;&lt;span class="p"&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="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="p"&gt;;&lt;/span&gt;
  &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;sprites&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;abilities&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="n"&gt;PokemonInfo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="kd"&gt;required&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;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="kd"&gt;required&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;height&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="kd"&gt;required&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;weight&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="kd"&gt;required&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="p"&gt;,&lt;/span&gt;
      &lt;span class="kd"&gt;required&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;name&lt;/span&gt;&lt;span class="p"&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;sprites&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="kd"&gt;required&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;abilities&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the code snippet above, you just created a model, and the model is called “&lt;strong&gt;PokemonInfo&lt;/strong&gt;”. The “&lt;strong&gt;PokemonInfo&lt;/strong&gt;”  class represents a Pokemon information object with properties like "&lt;strong&gt;type&lt;/strong&gt;", "&lt;strong&gt;height&lt;/strong&gt;", "&lt;strong&gt;weight&lt;/strong&gt;", "&lt;strong&gt;id&lt;/strong&gt;", "&lt;strong&gt;name&lt;/strong&gt;", "&lt;strong&gt;sprites&lt;/strong&gt;", and "&lt;strong&gt;abilities&lt;/strong&gt;". The class has a constructor that assigns named parameters to the corresponding class properties.&lt;/p&gt;

&lt;h3&gt;
  
  
  Parse JSON Data and convert it into a Dart object.
&lt;/h3&gt;

&lt;p&gt;As I mentioned earlier the “&lt;strong&gt;PokemonInfo&lt;/strong&gt;” class is also going to have a function to convert the JSON data to a dart object so let’s do that.&lt;/p&gt;

&lt;p&gt;Import the “&lt;strong&gt;dart:convert&lt;/strong&gt;” file into the file so that we can convert the data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The next step is to write the function called “&lt;strong&gt;pokemonInfoFromJson&lt;/strong&gt;” inside the “&lt;strong&gt;pokemonInfo&lt;/strong&gt;” class.&lt;/p&gt;

&lt;p&gt;The "&lt;strong&gt;pokemonInfoFromJson&lt;/strong&gt;" function takes a JSON string as input (String str). It uses the "&lt;strong&gt;json.decode"&lt;/strong&gt; function from the &lt;strong&gt;"dart:convert"&lt;/strong&gt; library to parse the JSON string into a dynamic data structure. It calls the "&lt;strong&gt;PokemonInfo.fromJson"&lt;/strong&gt; factory constructor passing the decoded JSON data and it returns the created "&lt;strong&gt;PokemonInfo"&lt;/strong&gt; object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;PokemonInfo&lt;/span&gt; &lt;span class="nf"&gt;pokemonInfoFromJson&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;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;PokemonInfo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fromJson&lt;/span&gt;&lt;span class="p"&gt;(&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="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="kd"&gt;factory&lt;/span&gt; &lt;span class="n"&gt;PokemonInfo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fromJson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;dynamic&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;PokemonInfo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="nl"&gt;type:&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'types'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s"&gt;'type'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s"&gt;'Unkwown'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;height:&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'height'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;weight:&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'weight'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;id:&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;name:&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'species'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s"&gt;'Unkwown'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;sprites:&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'sprites'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'sprites'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s"&gt;'other'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s"&gt;'home'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s"&gt;'front_default'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;abilities:&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'abilities'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s"&gt;'ability'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s"&gt;'Unkwown'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function above has a factory constructor called "&lt;strong&gt;fromJson"&lt;/strong&gt; that takes a "&lt;strong&gt;Map&amp;lt;String, dynamic&amp;gt;"&lt;/strong&gt; as input (json).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Inside the "&lt;strong&gt;fromJson"&lt;/strong&gt; factory constructor, it extracts the required data from the json map and assigns them to the class properties.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The "&lt;strong&gt;type&lt;/strong&gt;" is extracted from the JSON structure: &lt;strong&gt;json['types'][0]['type']['name']&lt;/strong&gt;. If it is not available, the default value '&lt;em&gt;Unknown&lt;/em&gt;' is used.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The "&lt;strong&gt;height&lt;/strong&gt;" is extracted from &lt;strong&gt;json['height']&lt;/strong&gt;. If it is not available, the default value &lt;em&gt;0&lt;/em&gt; is used.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The "&lt;strong&gt;weight&lt;/strong&gt;" is extracted from &lt;strong&gt;json['weight']&lt;/strong&gt;. If it is not available, the default value &lt;em&gt;0&lt;/em&gt; is used.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The "&lt;strong&gt;id&lt;/strong&gt;" is extracted from &lt;strong&gt;json['id']&lt;/strong&gt;. If it is not available, the default value &lt;em&gt;0&lt;/em&gt; is used.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The "&lt;strong&gt;name&lt;/strong&gt;" is extracted from &lt;strong&gt;json['species']['name']&lt;/strong&gt;. If it is not available, the default value '&lt;em&gt;Unknown&lt;/em&gt;' is used.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The “&lt;strong&gt;sprites&lt;/strong&gt;” are extracted from &lt;strong&gt;json['sprites']['other']['home']['front_default']&lt;/strong&gt;. If it is not available, it is assigned as &lt;em&gt;null&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The “&lt;strong&gt;abilities&lt;/strong&gt;” are extracted from &lt;strong&gt;json['abilities'][0]['ability']['name']&lt;/strong&gt;. If it is not available, the default value '&lt;em&gt;Unknown&lt;/em&gt;' is used.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The purpose of this code is to provide a way to convert the JSON data into a Dart object (&lt;strong&gt;PokemonInfo&lt;/strong&gt;) that represents Pokemon information. The fromJson factory constructor is responsible for extracting the necessary data from the JSON map and creating an instance of the "&lt;strong&gt;PokemonInfo"&lt;/strong&gt; class.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fetch Pokémon Data from the API
&lt;/h2&gt;

&lt;p&gt;Now that we have the foundation in place, let's fetch Pokémon data from the API and dynamically populate our cards. We'll modify our "&lt;strong&gt;fetchData()"&lt;/strong&gt; function we talked about in the Making HTTP Requests with Dart section to handle this:&lt;/p&gt;

&lt;p&gt;Create a folder inside the lib folder called services, and then in this services folder, you’ll create a file called "&lt;a href="http://networking.data" rel="noopener noreferrer"&gt;&lt;strong&gt;networking.data&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;"&lt;/strong&gt;; this is the file where you will write the code for the HTTP GET request;&lt;/p&gt;

&lt;p&gt;Import the necessary packages which are “&lt;strong&gt;dart convert&lt;/strong&gt;” and "&lt;strong&gt;http_package"&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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: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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The next thing you will do is to create a function similar to the one in “&lt;strong&gt;Making a GET request&lt;/strong&gt;”&lt;/p&gt;

&lt;h3&gt;
  
  
  Get the API URL and endpoints
&lt;/h3&gt;

&lt;p&gt;This is the API URL: '&lt;a href="https://pokeapi.co/api/v2/pokemon/" rel="noopener noreferrer"&gt;https://pokeapi.co/api/v2/pokemon/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The endpoint is: /ditto&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;N/B&lt;/strong&gt;: you will change the endpoint to use a number to index the character instead of a name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;Future&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;PokemonInfo&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;getpokemondata&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kd"&gt;async&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;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'https://pokeapi.co/api/v2/pokemon/1'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&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="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Uri&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;statusCode&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&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;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;decodedData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;jsonDecode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;PokemonInfo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fromJson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;decodedData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s"&gt;'failed to load data : &lt;/span&gt;&lt;span class="si"&gt;${response.statusCode}&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is a debugging technique to know if your request was successful or unsuccessful, which is to print the "&lt;strong&gt;response.statusCode"&lt;/strong&gt; or the "&lt;strong&gt;response.body"&lt;/strong&gt; in the if statement, it will tell you what status code you got; 200 means it was successful, but remember to remove the print statement after verifying.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.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%2Frxdd2n7qgz86gddmqo5t.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Frxdd2n7qgz86gddmqo5t.jpg" alt="response.statusCode"&gt;&lt;/a&gt;nter")&lt;/p&gt;

&lt;p&gt;Fig 2. Status code on debug console&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.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%2Fuzia9jk4wq4x8zlpqkli.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fuzia9jk4wq4x8zlpqkli.jpg" alt="response.statusCode"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig 3. Response body on the debug console&lt;/p&gt;

&lt;p&gt;The "&lt;strong&gt;getPokemonData()"&lt;/strong&gt; function above uses the "&lt;strong&gt;HTTP GET"&lt;/strong&gt; function from the HTTP package in Dart to request data from the Pokémon API by parsing the URL value into the &lt;strong&gt;GET&lt;/strong&gt; function. If the response is successful, you receive the details of a specific Pokémon and parse them to the dart object you created earlier. If the response is unsuccessful, you will receive an error.&lt;/p&gt;

&lt;h3&gt;
  
  
  Parse the API Response and Extract Relevant Data
&lt;/h3&gt;

&lt;p&gt;Once the API response is obtained, the next step is to parse the response and extract the relevant data. In this case, the response is in JSON format, so we use the "&lt;strong&gt;jsonDecode()"&lt;/strong&gt; function from the "&lt;strong&gt;dart:convert"&lt;/strong&gt; package to convert the JSON data into a Dart object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;Data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;jsonDecode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Data variable now holds the parsed JSON response as a Dart object. You can extract specific information about the Pokémon from this object, such as its name, abilities, stats, types, etc.&lt;/p&gt;

&lt;p&gt;For example, if you want to extract the name of the Pokémon, you can access it using the appropriate key or field from the parsed object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;pokemonName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Similarly, you can extract other relevant information based on the structure of the API response. But you will not access the information like the above; you will access it from the "&lt;strong&gt;PokemonInfo&lt;/strong&gt;" class you created that receives the response from the API and holds it for future use.&lt;/p&gt;

&lt;h2&gt;
  
  
  Display the Pokemon Data on the Pokemon Card
&lt;/h2&gt;

&lt;p&gt;This section is where we use the data we have gotten from the API to populate our card.&lt;/p&gt;

&lt;p&gt;Create a file in the lib folder called "&lt;strong&gt;home.dart"&lt;/strong&gt;, where you will use the flipping card we created to show the Pokemon data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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:math'&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:flutter_spinkit/flutter_spinkit.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:pokemon_card/models/pokemon.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:pokemon_card/services/networking.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;'utilities/fliping_card.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;HomePage&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatefulWidget&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;HomePage&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&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="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;HomePage&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;createState&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;_HomePageState&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;_HomePageState&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;State&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;HomePage&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;late&lt;/span&gt; &lt;span class="n"&gt;Future&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;PokemonInfo&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;getpokemon&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;initState&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;getpokemon&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;getpokemondata&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;initState&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&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="p"&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="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Scaffold&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;backgroundColor:&lt;/span&gt; &lt;span class="n"&gt;Colors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;purpleAccent&lt;/span&gt;&lt;span class="p"&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="p"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;backgroundColor:&lt;/span&gt; &lt;span class="n"&gt;Colors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;purple&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nl"&gt;elevation:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nl"&gt;title:&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="p"&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="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'POKEMON CARD'&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
      &lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="nl"&gt;body:&lt;/span&gt; &lt;span class="n"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;children:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
          &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;SizedBox&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;height:&lt;/span&gt; &lt;span class="mi"&gt;35&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
          &lt;span class="n"&gt;Expanded&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;FutureBuilder&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;PokemonInfo&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;
                &lt;span class="nl"&gt;future:&lt;/span&gt; &lt;span class="n"&gt;getpokemon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="nl"&gt;builder:&lt;/span&gt; &lt;span class="p"&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="p"&gt;,&lt;/span&gt;
                    &lt;span class="n"&gt;AsyncSnapshot&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;PokemonInfo&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;connectionState&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;ConnectionState&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;waiting&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;SpinKitRotatingPlain&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                      &lt;span class="nl"&gt;size:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                      &lt;span class="nl"&gt;color:&lt;/span&gt; &lt;span class="n"&gt;Colors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;yellow&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="p"&gt;);&lt;/span&gt;
                  &lt;span class="p"&gt;}&lt;/span&gt;
                  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;hasError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&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="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
                  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;FlippingPokemonCard&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                      &lt;span class="nl"&gt;abilities:&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="o"&gt;!.&lt;/span&gt;&lt;span class="na"&gt;abilities&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                      &lt;span class="nl"&gt;height:&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="o"&gt;!.&lt;/span&gt;&lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                      &lt;span class="nl"&gt;id:&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="o"&gt;!.&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                      &lt;span class="nl"&gt;name:&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="o"&gt;!.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                      &lt;span class="nl"&gt;sprites:&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="o"&gt;?.&lt;/span&gt;&lt;span class="na"&gt;sprites&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt;
                          &lt;span class="s"&gt;"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/home/1.png"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                      &lt;span class="nl"&gt;type:&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="o"&gt;!.&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                      &lt;span class="nl"&gt;weight:&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="o"&gt;!.&lt;/span&gt;&lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="p"&gt;);&lt;/span&gt;
                  &lt;span class="p"&gt;}&lt;/span&gt;
                &lt;span class="p"&gt;}),&lt;/span&gt;
          &lt;span class="p"&gt;),&lt;/span&gt;
          &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;SizedBox&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="nl"&gt;height:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;],&lt;/span&gt;
      &lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's start with the imports in the "&lt;strong&gt;home.dart"&lt;/strong&gt; file;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;package:flutter/material.dart&lt;/strong&gt;: This import provides Flutter's Material UI components.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;package:flutter_spinkit/flutter_spinkit.dart&lt;/strong&gt;: This import includes pre-built loading spinners.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;package:pokemon_card/models/pokemon.dart&lt;/strong&gt;: This import refers to the PokemonInfo class that represents Pokémon information.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;package:pokemon_card/services/networking.dart:&lt;/strong&gt; This import refers to the "&lt;strong&gt;getpokemondata"&lt;/strong&gt; function fetching Pokémon data from a network.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;utilities/fliping_card.dart&lt;/strong&gt;: This import is for the FlippingPokemonCard widget that represents the Pokémon card with flipping animation.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After that, Create a "&lt;strong&gt;StatefulWidget"&lt;/strong&gt; called &lt;strong&gt;"HomePage"&lt;/strong&gt;, which represents the application's main page. The constructor doesn't have any parameters, and it overrides the "&lt;strong&gt;createState"&lt;/strong&gt; method to create an instance of the "&lt;strong&gt;_HomePageState"&lt;/strong&gt; class.&lt;/p&gt;

&lt;p&gt;In the "&lt;strong&gt;HomePage"&lt;/strong&gt; declare the necessary variable "&lt;strong&gt;getpokemon&lt;/strong&gt;"&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;late&lt;/span&gt; &lt;span class="n"&gt;Future&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;PokemonInfo&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;getpokemon&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The "&lt;strong&gt;getpokemon"&lt;/strong&gt; variable is a Future variable with the type &lt;strong&gt;"PokemonInfo"&lt;/strong&gt; that holds the result of fetching Pokémon data asynchronously.&lt;/p&gt;

&lt;p&gt;In the "&lt;strong&gt;initState"&lt;/strong&gt; method inside the HomePage stateful widget, call the "&lt;strong&gt;getpokemondata"&lt;/strong&gt; function to fetch Pokémon data asynchronously and assign the result to the "&lt;strong&gt;getpokemon&lt;/strong&gt;" variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="nd"&gt;@override&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;initState&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;getpokemon&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;getpokemondata&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;initState&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The "&lt;strong&gt;super.initState()"&lt;/strong&gt; is called to ensure the parent class's initState method is executed.&lt;/p&gt;

&lt;p&gt;In the build method, return a "&lt;strong&gt;Scaffold"&lt;/strong&gt; widget that provides the basic structure of the page.&lt;/p&gt;

&lt;p&gt;The "&lt;strong&gt;Scaffold"&lt;/strong&gt; has a purple accent background color and an "&lt;strong&gt;AppBar"&lt;/strong&gt; at the top with a purple background.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;Scaffold&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="nl"&gt;backgroundColor:&lt;/span&gt; &lt;span class="n"&gt;Colors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;purpleAccent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The "&lt;strong&gt;AppBar"&lt;/strong&gt; contains a centered title with the text "POKEMON CARD".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="nl"&gt;appBar:&lt;/span&gt; &lt;span class="n"&gt;AppBar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="nl"&gt;backgroundColor:&lt;/span&gt; &lt;span class="n"&gt;Colors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;purple&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;elevation:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;title:&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="p"&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="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'POKEMON CARD'&lt;/span&gt;&lt;span class="p"&gt;)),),&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The body of the "&lt;strong&gt;Scaffold"&lt;/strong&gt; is a "&lt;strong&gt;Column&lt;/strong&gt;" widget with the following necessary components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A "&lt;strong&gt;SizedBox"&lt;/strong&gt; for adding vertical spacing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An "&lt;strong&gt;Expanded"&lt;/strong&gt; widget that contains a FutureBuilder for asynchronously building the Pokémon card based on the fetched data.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Use the Future Builder to Display the Pokemon Card
&lt;/h3&gt;

&lt;p&gt;Let me explain the future builder and how we use it in our project.&lt;/p&gt;

&lt;p&gt;The "&lt;strong&gt;FutureBuilder"&lt;/strong&gt; widget is a great tool in Flutter that allows you to handle asynchronous operations and update the user interface based on the current state of the future. It simplifies the process of managing and displaying data that is being fetched asynchronously.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;future&lt;/strong&gt;: "&lt;strong&gt;getpokemon"&lt;/strong&gt; specifies the future that the FutureBuilder will monitor. In this case, "&lt;strong&gt;getpokemon"&lt;/strong&gt; is a function or method that returns a "&lt;strong&gt;Future&amp;lt;PokemonInfo&amp;gt;"&lt;/strong&gt; object.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;builder&lt;/strong&gt;: builder is a callback function that defines the UI based on the current state of the future. It takes in two parameters: the BuildContext and an "&lt;strong&gt;AsyncSnapshot&amp;lt;PokemonInfo&amp;gt;"&lt;/strong&gt; object, representing the future's current state.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Inside the builder function, the code checks the "&lt;strong&gt;connectionState"&lt;/strong&gt; property of the snapshot object to determine the current state of the future.&lt;/p&gt;

&lt;p&gt;If the connection state is "&lt;strong&gt;ConnectionState.waiting"&lt;/strong&gt;, the future is still in progress. In this case, a SpinKitRotatingPlain widget is returned, which could be a loading indicator or any other widget indicating that the data is being fetched.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;FutureBuilder&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;PokemonInfo&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;
&lt;span class="nl"&gt;future:&lt;/span&gt; &lt;span class="n"&gt;getpokemon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;builder:&lt;/span&gt;
&lt;span class="p"&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="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;AsyncSnapshot&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;PokemonInfo&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;connectionState&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;ConnectionState&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;waiting&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nf"&gt;SpinKitRotatingPlain&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="nl"&gt;size:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;color:&lt;/span&gt; &lt;span class="n"&gt;Colors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;yellow&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the snapshot has an error, the snapshot.hasError condition will be true. In this case, an error message is displayed using a Text widget, showing the error message obtained from snapshot.error.toString().&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;hasError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the connection state is not waiting and there is no error (else condition), the future has been completed successfully, and the data is available in "&lt;a href="http://snapshot.data" rel="noopener noreferrer"&gt;snapshot.data&lt;/a&gt;".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;FlippingPokemonCard&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="nl"&gt;abilities:&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="o"&gt;!.&lt;/span&gt;&lt;span class="na"&gt;abilities&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;height:&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="o"&gt;!.&lt;/span&gt;&lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;id:&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="o"&gt;!.&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;name:&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="o"&gt;!.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;sprites:&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="o"&gt;?.&lt;/span&gt;&lt;span class="na"&gt;sprites&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s"&gt;"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/home/1.png"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;type:&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="o"&gt;!.&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;weight:&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="o"&gt;!.&lt;/span&gt;&lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside the else block, our FlippingPokemonCard widget is returned, which uses the data obtained from "&lt;a href="http://snapshot.data" rel="noopener noreferrer"&gt;&lt;strong&gt;snapshot.data&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;"&lt;/strong&gt;. This widget receives properties like abilities, height, id, name, sprites, `&lt;/p&gt;

&lt;p&gt;So if everything works fine the picture below should be what you see;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fixymybnsl84zmmpj7gwh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fixymybnsl84zmmpj7gwh.png" alt="Front of the card"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig 4. Front of the card&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fcoyfbbbjzl8g2iy8r7y9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fcoyfbbbjzl8g2iy8r7y9.png" alt="Back of the card"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig 4. Back of the card&lt;/p&gt;

&lt;p&gt;And if it doesn’t work as planned you should see the picture below;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fcg08hts9bkoblta87zht.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fcg08hts9bkoblta87zht.png" alt=" Error message"&gt;&lt;/a&gt;&lt;br&gt;
fig 5. Error message&lt;/p&gt;

&lt;h2&gt;
  
  
  Generate Pokémon Cards Dynamically
&lt;/h2&gt;

&lt;p&gt;We have succeeded in showing a Pokemon character on our card. Still, it's just one character that is showing, and this project aims to randomly generate different Pokemon characters every time a button is pressed, so let's do that now.&lt;/p&gt;

&lt;p&gt;So firstly, modify our "&lt;strong&gt;getpokemon"&lt;/strong&gt; function to accept an int value parameter called "&lt;strong&gt;characterid&lt;/strong&gt;";&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;dart&lt;br&gt;
Future&amp;lt;PokemonInfo&amp;gt; getpokemondata( int characterid) async {    String url ='https://pokeapi.co/api/v2/pokemon/$characterid';    final response = await http.get(Uri.parse(url));    if (response.statusCode == 200) {&lt;br&gt;
String data = response.body;&lt;br&gt;
final decodedData = jsonDecode(data);&lt;br&gt;
return PokemonInfo.fromJson(decodedData);&lt;br&gt;
} else {&lt;br&gt;
throw 'failed to load data : ${response.statusCode}';&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;With this int variable in place, you now have a placeholder for the random numbers in the function,&lt;/p&gt;

&lt;p&gt;Let's move on to the next part, which is in the "&lt;strong&gt;home.dart"&lt;/strong&gt; file. In this file, create a variable of type int under the "&lt;strong&gt;getpokemon"&lt;/strong&gt; variable and call it "&lt;strong&gt;number&lt;/strong&gt;".&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`dart&lt;/p&gt;

&lt;p&gt;late int number;&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The next thing you will do is give the number variable we just created a value inside the "&lt;strong&gt;initState"&lt;/strong&gt;, but there's a twist to it; you will not give the variable a static value; you will provide it with a value that changes.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`dart&lt;/p&gt;

&lt;p&gt;&lt;a class="mentioned-user" href="https://dev.to/override"&gt;@override&lt;/a&gt;&lt;br&gt;
void initState() {&lt;br&gt;
number = Random().nextInt(1000);&lt;br&gt;
getpokemon = getpokemondata(number);&lt;br&gt;
super.initState();&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The value of the "&lt;strong&gt;number&lt;/strong&gt;" variable is a method from "&lt;strong&gt;dart:math"&lt;/strong&gt; that generates non-negative random numbers within a specific range; in this case, the range is 1000.&lt;/p&gt;

&lt;p&gt;Parse this new variable into the instance of our "&lt;strong&gt;getpokemondata"&lt;/strong&gt; function in the "&lt;strong&gt;initState"&lt;/strong&gt;, as shown above.&lt;/p&gt;

&lt;p&gt;So now you should see a new Pokemon character every time you restart your app. But you are not done yet because you don't want to restart our app every time to display a new character, which brings us to the next part, creating a generate button to generate a new character every time it is pressed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a Custom Button
&lt;/h3&gt;

&lt;p&gt;Create a file in the "&lt;strong&gt;utilities&lt;/strong&gt;" folder called "&lt;strong&gt;generate_button.dart"&lt;/strong&gt;, and in this file, you will create the custom button.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`dart&lt;/p&gt;

&lt;p&gt;import 'package:flutter/material.dart';&lt;/p&gt;

&lt;p&gt;class GenerateButton extends StatelessWidget {&lt;br&gt;
  const GenerateButton({super.key, required this.function});&lt;/p&gt;

&lt;p&gt;final  Function()? function;&lt;/p&gt;

&lt;p&gt;&lt;a class="mentioned-user" href="https://dev.to/override"&gt;@override&lt;/a&gt;&lt;br&gt;
  Widget build(BuildContext context) {&lt;br&gt;
    return GestureDetector(&lt;br&gt;
      onTap: function,&lt;br&gt;
      child: Container(&lt;br&gt;
        height: 50,&lt;br&gt;
        width: 150,&lt;br&gt;
        decoration: BoxDecoration(&lt;br&gt;
          borderRadius: BorderRadius.circular(10),&lt;br&gt;
          color: Colors.yellow,&lt;br&gt;
          boxShadow: const [&lt;br&gt;
            BoxShadow(&lt;br&gt;
                color: Colors.black,&lt;br&gt;
                offset: Offset(0, 3.0),&lt;br&gt;
                blurRadius: 1.0,&lt;br&gt;
                spreadRadius: 1.0)&lt;br&gt;
          ],&lt;br&gt;
        ),&lt;br&gt;
        child: const Center(&lt;br&gt;
            child: Text(&lt;br&gt;
          'Generate',&lt;br&gt;
          style: TextStyle(fontSize: 20, fontWeight: FontWeight.w300),&lt;br&gt;
        )),&lt;br&gt;
      ),&lt;br&gt;
    );&lt;br&gt;
  }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In the above code, we have successfully created a custom button, which is a stateless widget that returns a container wrapped with the GestureDetector widget.&lt;/p&gt;

&lt;p&gt;The GestureDetector widget has a property called "&lt;strong&gt;onTap&lt;/strong&gt;" this property is a "&lt;strong&gt;function?&lt;/strong&gt;" that returns a function of type void, so we created a variable called "&lt;strong&gt;function"&lt;/strong&gt; to receive a function when tapped later.&lt;/p&gt;

&lt;p&gt;The "&lt;strong&gt;container"&lt;/strong&gt; also has a child, which is a text widget saying "&lt;strong&gt;Generate&lt;/strong&gt;".&lt;/p&gt;

&lt;p&gt;It is time to use the custom button you created in the "&lt;strong&gt;home.dart"&lt;/strong&gt; file,&lt;/p&gt;

&lt;p&gt;At the bottom of the "&lt;strong&gt;column"&lt;/strong&gt;, let's use the custom button that we named "&lt;strong&gt;generateButton&lt;/strong&gt;", When you use the button, you will see that we get an error saying we have a required parameter called "&lt;strong&gt;function"&lt;/strong&gt; that we need to fill. It is now time to write the function that randomly generates the Pokemon characters.&lt;/p&gt;

&lt;p&gt;Under the "&lt;strong&gt;initState"&lt;/strong&gt; is where you’ll put the code below;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`dart&lt;/p&gt;

&lt;p&gt;void generateRandomPokemon() {&lt;br&gt;
setState(() {&lt;br&gt;
number = Random().nextInt(1000);&lt;br&gt;
getpokemon = getpokemondata(number);&lt;br&gt;
});&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The code above is a function called "&lt;strong&gt;generateRandomPokemon&lt;/strong&gt;" That doesn't return any value. The main aim of this function is to recall the "&lt;strong&gt;number&lt;/strong&gt;" variable and then parse the new value to the "&lt;strong&gt;getpokemondata&lt;/strong&gt;" function.&lt;/p&gt;

&lt;p&gt;The "&lt;strong&gt;setState"&lt;/strong&gt; ensures that when a new int value is parsed, it marks the UI as dirty and reloads the UI with the Pokemon character corresponding with the present int value.&lt;/p&gt;

&lt;p&gt;We have finished writing the function to generate a new character for the Pokemon card randomly. It's now time to use this function on the generate button.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;dart&lt;br&gt;
GenerateButton(function: generateRandomPokemon),&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fwk5wlshbflwpoyei2r6o.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fwk5wlshbflwpoyei2r6o.jpg" alt=" button called Generate "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig 6.  A button called Generate is tapped, and the character changes&lt;/p&gt;

&lt;p&gt;Now, whenever you tap the generate button, the app will reload with a different Pokemon character on the card.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enhance the User Experience
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Loading Indicators
&lt;/h3&gt;

&lt;p&gt;To let the users know that the app is doing some work in the background, you display a loading indicator while fetching data from the API. You can use the CircularProgressIndicator or a package like flutter_spinkit for custom loading spinners, and we used both for this project.&lt;/p&gt;

&lt;p&gt;Wrap your FutureBuilder widget's child with the loading indicator widget and conditionally show it based on "&lt;strong&gt;snapshot.connectionState"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example, if the connection state is "&lt;strong&gt;ConnectionState.waiting"&lt;/strong&gt;, show the loading indicator widget.&lt;/p&gt;

&lt;p&gt;Here's an example code snippet to demonstrate what we did earlier:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;dart&lt;br&gt;
if (snapshot.connectionState == ConnectionState.waiting) { &lt;br&gt;
return Center(&lt;br&gt;
 child: CircularProgressIndicator(),&lt;br&gt;
) // or any other loading indicator widget ); }&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Error Handling
&lt;/h3&gt;

&lt;p&gt;Error handling in Flutter refers to gracefully handling and managing errors or exceptions that occur during the execution of your app. Flutter provides various mechanisms to handle errors effectively and provide a good user experience. Here are some common error-handling techniques in Flutter:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Try-Catch Blocks&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Error Callbacks&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Flutter Error Widget&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will be using the try-catch block for this project.&lt;/p&gt;

&lt;h4&gt;
  
  
  Try-Catch Blocks
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;dart&lt;br&gt;
try {&lt;br&gt;
// Code that might throw an exception&lt;br&gt;
} catch (e) {&lt;br&gt;
// Handle the exception&lt;br&gt;
}&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can use try-catch blocks to catch and handle exceptions in Dart. The "&lt;strong&gt;try"&lt;/strong&gt; part of the function tries to execute a function and return a value, if, along the way an error occurs, the "&lt;strong&gt;catch"&lt;/strong&gt; part handles it. We will place the "&lt;strong&gt;getpokemondata&lt;/strong&gt;" function that might throw an exception inside a "&lt;strong&gt;try"&lt;/strong&gt; block and use a generic catch block to handle any exception. This will allow us to handle errors and provide appropriate feedback to the user.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;dart&lt;br&gt;
Future&amp;lt;PokemonInfo&amp;gt; getpokemondata(int characterid) async {&lt;br&gt;
  try {&lt;br&gt;
    String url = 'https://pokeapi.co/api/v2/pokemon/$characterid';&lt;br&gt;
    final response = await http.get(Uri.parse(url));&lt;br&gt;
    if (response.statusCode == 200) {&lt;br&gt;
      String data = response.body;&lt;br&gt;
      final decodedData = jsonDecode(data);&lt;br&gt;
      return PokemonInfo.fromJson(decodedData);&lt;br&gt;
    } else {&lt;br&gt;
      throw 'failed to load data : ${response.statusCode}';&lt;br&gt;
    }&lt;br&gt;
  } catch (e) {&lt;br&gt;
    throw e.toString();&lt;br&gt;
  }&lt;br&gt;
}&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;At this point, the error handling of the app is 90 percent complete; the remaining 10 percent is the fact that we are catching the exception but not notifying the users of what is going on. Let's fix that by showing the users a dialog box anytime we catch an exception.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;strong&gt;Create a Dialog Box&lt;/strong&gt;
&lt;/h5&gt;

&lt;p&gt;To create a dialog box for this project, Create a file in the "&lt;strong&gt;utilities&lt;/strong&gt;" folder called "&lt;strong&gt;show_error_dialog.dart&lt;/strong&gt;", where we will write the code to show the dialog box.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`dart&lt;br&gt;
import 'package:flutter/material.dart';&lt;/p&gt;

&lt;p&gt;Future showErrorDialog(&lt;br&gt;
  BuildContext context,&lt;br&gt;
  String text,&lt;br&gt;
) {&lt;br&gt;
  return showDialog(&lt;br&gt;
      context: context,&lt;br&gt;
      builder: (context) {&lt;br&gt;
        return AlertDialog(&lt;br&gt;
          title: const Text('An error occurred'),&lt;br&gt;
          content: Text(text),&lt;br&gt;
          actions: [&lt;br&gt;
            TextButton(&lt;br&gt;
                onPressed: () {&lt;br&gt;
                  Navigator.of(context).pop();&lt;br&gt;
                },&lt;br&gt;
                child: const Text('OK'))&lt;br&gt;
          ],&lt;br&gt;
        );&lt;br&gt;
      });&lt;br&gt;
}&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This code snippet above is the function that will display an error dialog to the user.&lt;/p&gt;

&lt;p&gt;Let's break it down step by step:&lt;/p&gt;

&lt;p&gt;The function "&lt;strong&gt;showErrorDialog&lt;/strong&gt;" takes two parameters: "&lt;strong&gt;context&lt;/strong&gt;", which is the current "&lt;strong&gt;BuildContext"&lt;/strong&gt; of the app, and "&lt;strong&gt;text&lt;/strong&gt;", which is the error message to be displayed in the dialog.&lt;/p&gt;

&lt;p&gt;Then inside the function, we call the "&lt;strong&gt;showDialog&lt;/strong&gt;" function, which is a built-in Flutter method that displays a dialog on the screen.&lt;/p&gt;

&lt;p&gt;The "&lt;strong&gt;showDialog&lt;/strong&gt;" function takes a "&lt;strong&gt;context&lt;/strong&gt;" parameter and a "&lt;strong&gt;builder&lt;/strong&gt;" function that returns the content of the dialog. The "&lt;strong&gt;builder&lt;/strong&gt;" function is defined as "&lt;strong&gt;(context)&lt;/strong&gt;", where context represents the "&lt;strong&gt;BuildContext&lt;/strong&gt;" passed to it. It returns an "&lt;strong&gt;AlertDialog&lt;/strong&gt;" widget, a pre-designed dialog widget.&lt;/p&gt;

&lt;p&gt;The "&lt;strong&gt;AlertDialog&lt;/strong&gt;" widget has a title, content, and actions. The title is set to '&lt;em&gt;An error occurred&lt;/em&gt;', and the content is set to the "&lt;strong&gt;text&lt;/strong&gt;" parameter containing the error message.&lt;/p&gt;

&lt;p&gt;In the actions property, we set a list containing a single "&lt;strong&gt;TextButton&lt;/strong&gt;" widget. This button is labeled '&lt;em&gt;OK&lt;/em&gt;' and has an "&lt;strong&gt;onPressed&lt;/strong&gt;" callback that closes the dialog by calling "&lt;strong&gt;Navigator.of(context).pop()&lt;/strong&gt;". Finally, the "&lt;strong&gt;showDialog&lt;/strong&gt;" function is returned, which displays the error dialog for the user.&lt;/p&gt;

&lt;p&gt;You have to change the "&lt;strong&gt;getpokemondata"&lt;/strong&gt; function again to show a dialog box when an exception is caught.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;dart&lt;br&gt;
Future&amp;lt;PokemonInfo&amp;gt; getpokemondata(&lt;br&gt;
    BuildContext context, int characterid) async {&lt;br&gt;
  try {&lt;br&gt;
    String url = 'https://pokeapi.co/api/v2/pokemon/$characterid';&lt;br&gt;
    final response = await http.get(Uri.parse(url));&lt;br&gt;
    if (response.statusCode == 200) {&lt;br&gt;
      String data = response.body;&lt;br&gt;
      final decodedData = jsonDecode(data);&lt;br&gt;
      return PokemonInfo.fromJson(decodedData);&lt;br&gt;
    } else {&lt;br&gt;
      throw 'failed to load data : ${response.statusCode}';&lt;br&gt;
    }&lt;br&gt;
  } catch (e) {&lt;br&gt;
    showErrorDialog(context, 'An error occurred: $e');&lt;br&gt;
    throw e.toString();&lt;br&gt;
  }&lt;br&gt;
}&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The "&lt;strong&gt;BuildContext&lt;/strong&gt;" which is added to the parameter of the "&lt;strong&gt;getpokemondata&lt;/strong&gt;" function, is an object that represents the location of a widget within the widget tree hierarchy. It provides access to various information and functionalities related to the widget's position and the overall app context.&lt;/p&gt;

&lt;p&gt;The "&lt;strong&gt;showErrorDialog"&lt;/strong&gt; function, which we have added to the "&lt;strong&gt;catch&lt;/strong&gt;" part of the try-catch block, is the custom function we created to display an error dialog to the user. It takes two parameters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;context&lt;/strong&gt;: This is the "&lt;strong&gt;BuildContext"&lt;/strong&gt; of the current widget. It is required to show the dialog within the appropriate context of the app.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;text&lt;/strong&gt;: This parameter represents the error message to be displayed in the dialog; in this case, it is the error that occurred.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You have successfully handled any exception that may occur during the fetching of the data from the API. Also, you have created a dialog box to notify the user about the exception.&lt;/p&gt;

&lt;p&gt;If you can recall, you called "&lt;strong&gt;getpokemondata&lt;/strong&gt;" at two places in the "&lt;strong&gt;home.dart&lt;/strong&gt;" file, so at this point, you should be having an error saying, "&lt;em&gt;2 positional arguments expected by 'getpokemondata', but 1 found. Try adding the missing arguments&lt;/em&gt;".&lt;/p&gt;

&lt;p&gt;Don't panic; all you have to do is add "&lt;strong&gt;context&lt;/strong&gt;" to the function, and the error should go away. By parsing the "&lt;strong&gt;contex&lt;/strong&gt;t" from the calling widget to the &lt;strong&gt;getpokemondata"&lt;/strong&gt; function, we ensure that the error dialog is displayed within the correct context of the app. This is important because the dialog needs to overlay the current screen and be aware of the app's state and navigation stack.&lt;/p&gt;

&lt;p&gt;Anytime there’s an error, the "&lt;strong&gt;try-catch"&lt;/strong&gt; block will catch it, and we will also let the user know what is going on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fsou8qhjnk4nycx3l867v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fsou8qhjnk4nycx3l867v.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig 7. Alert dialog box&lt;/p&gt;

&lt;p&gt;In "&lt;strong&gt;home.dart&lt;/strong&gt;", you can say we are handling errors because you are using the "&lt;strong&gt;FutureBuilder"&lt;/strong&gt; widget's "&lt;strong&gt;snapshot.hasError"&lt;/strong&gt; property to check if an error occurred, and if an error occurs, we display an error message to the user. but you are not giving the user any dialog box to execute an action.&lt;/p&gt;

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

&lt;p&gt;This comprehensive guide taught you how to create an immersive Pokémon Card app using Dart and Flutter. By leveraging REST APIs, making network requests, handling data, and designing captivating user interfaces, you've gained valuable insights into the app development world using Flutter. The Pokémon Card app is a fun example of how to use APIs in our application and learn about Pokemon characters. With the foundation you've built, you can continue to enhance the app by implementing additional features such as search functionality and card sorting.&lt;/p&gt;

&lt;p&gt;Here is the link to the GitHub repo: &lt;a href="https://github.com/emjaycodes/pokemon_card" rel="noopener noreferrer"&gt;https://github.com/emjaycodes/pokemon_card&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Don't forget to leave a star on the repo.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>ui</category>
      <category>api</category>
    </item>
    <item>
      <title>Top 10 Tips for Building Beautiful UIs in Flutter</title>
      <dc:creator>emjaycodes</dc:creator>
      <pubDate>Sat, 18 Feb 2023 19:32:59 +0000</pubDate>
      <link>https://dev.to/emjaycodes/top-10-tips-for-building-beautiful-uis-in-flutter-1fd6</link>
      <guid>https://dev.to/emjaycodes/top-10-tips-for-building-beautiful-uis-in-flutter-1fd6</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Who does not love an eye-catching, immersive app? I'm guessing everyone does, and Flutter is a popular framework for building cross-platform mobile applications with beautiful and responsive user interfaces (UIs), which is so cool.&lt;/p&gt;

&lt;p&gt;As a Flutter developer, you have access to a wide range of widgets, tools, and resources that will help you create stunning UIs for your apps. In this article, I'll share ten tips that can help you improve the design and aesthetics of your Flutter UIs. Let's get right into it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Choose the Right Colors
&lt;/h3&gt;

&lt;p&gt;Colors play a vital role in the overall look and feel of your app. Make sure you choose the right color palette that reflects your brand, target audience, and app's purpose. You can use tools like &lt;a href="https://coolors.co/" rel="noopener noreferrer"&gt;Coolors&lt;/a&gt; or the &lt;a href="https://www.materialpalette.com/" rel="noopener noreferrer"&gt;Material Color Tool&lt;/a&gt; to generate attractive color schemes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use Appropriate Fonts
&lt;/h3&gt;

&lt;p&gt;Fonts can make or break the readability and user experience of your app. Choose a font that is easy to read and matches the tone and style of your app. Google Fonts provides a wide range of free and open-source fonts that you can use in your Flutter app.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use Responsive Layouts
&lt;/h3&gt;

&lt;p&gt;Flutter provides several layout widgets that can help you build responsive and flexible UIs that adapt to different screen sizes and orientations. Use widgets like Column, Row, and Expanded to create dynamic layouts that look great on any device.&lt;/p&gt;

&lt;h3&gt;
  
  
  Keep it Simple
&lt;/h3&gt;

&lt;p&gt;I know sometimes we would like to add some extras to our UI, but don't overload your UI with too much information or elements. Keep it simple and focus on the essential features of your app. Use whitespace and hierarchy to create a clean and visually appealing UI and also pay attention to negative spaces&lt;/p&gt;

&lt;h3&gt;
  
  
  Use Animations
&lt;/h3&gt;

&lt;p&gt;Animations can add a touch of magic and delight to your app. Flutter provides several animation widgets and classes that you can use to create smooth and engaging animations for your UI. Use them sparingly and purposefully to avoid overwhelming your users.&lt;/p&gt;

&lt;h3&gt;
  
  
  Provide Feedback
&lt;/h3&gt;

&lt;p&gt;Provide feedback to your users when they interact with your app. Use animations, sounds, or haptic feedback to let them know that their action has been acknowledged. This creates a sense of responsiveness and enhances the user experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use Icons
&lt;/h3&gt;

&lt;p&gt;Icons are a great way to convey information and actions without using too much text. Use icons that are consistent with your brand and easy to recognize. Flutter Icons provides a set of customizable icons that you can use in your app.&lt;/p&gt;

&lt;h3&gt;
  
  
  Optimize Images
&lt;/h3&gt;

&lt;p&gt;Images can significantly impact the performance and loading time of your app. Optimize your images by compressing them or using the right file format. You can use tools like &lt;a href="https://tinypng.com/" rel="noopener noreferrer"&gt;TinyPNG&lt;/a&gt; or &lt;a href="https://squoosh.app/" rel="noopener noreferrer"&gt;Squoosh&lt;/a&gt; to optimize your images.&lt;/p&gt;

&lt;h3&gt;
  
  
  Test on Real Devices
&lt;/h3&gt;

&lt;p&gt;Testing your app on real devices can help you identify UI issues that you might have missed during development. Use tools like &lt;a href="https://firebase.google.com/docs/test-lab" rel="noopener noreferrer"&gt;Firebase Test Lab&lt;/a&gt; or &lt;a href="https://aws.amazon.com/device-farm/" rel="noopener noreferrer"&gt;AWS Device Farm&lt;/a&gt; to test your app on a wide range of devices and platforms.&lt;/p&gt;

&lt;h3&gt;
  
  
  Get Inspired
&lt;/h3&gt;

&lt;p&gt;Don't be afraid to get inspired by other apps and designs. Look for design patterns and elements that you can use in your app. Platforms like &lt;a href="https://dribbble.com/" rel="noopener noreferrer"&gt;Dribbble&lt;/a&gt;, &lt;a href="https://www.behance.net/" rel="noopener noreferrer"&gt;Behance&lt;/a&gt;, and &lt;a href="https://www.pinterest.com/" rel="noopener noreferrer"&gt;Pinterest&lt;/a&gt; provide a wealth of design inspiration and ideas.&lt;/p&gt;

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

&lt;p&gt;Building beautiful UIs in Flutter requires a combination of design skills and technical knowledge. With these ten tips, you can improve the aesthetics and user experience of your Flutter app. Remember to keep it simple. use the right colors and fonts and provide feedback and animations to create an engaging and delightful UI. Happy designing.&lt;/p&gt;

</description>
      <category>coop</category>
      <category>gratitude</category>
    </item>
    <item>
      <title>A Simplistic Review of the Lifecycle of Flutter Widgets</title>
      <dc:creator>emjaycodes</dc:creator>
      <pubDate>Wed, 10 Aug 2022 19:12:28 +0000</pubDate>
      <link>https://dev.to/emjaycodes/a-simplistic-review-of-the-lifecycle-of-flutter-widgets-3632</link>
      <guid>https://dev.to/emjaycodes/a-simplistic-review-of-the-lifecycle-of-flutter-widgets-3632</guid>
      <description>&lt;p&gt;This is a concept that I couldn’t wrap my head around for a while, so I searched and tried to explain it in the simplest way I could, and I guess you’re probably trying to do the same If so, you’re at the right place. Let's get into it. &lt;/p&gt;

&lt;h2&gt;
  
  
  Stateless and Stateful widget
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Stateless widget
&lt;/h3&gt;

&lt;p&gt;These types of widgets don’t change state after they have been created. They are immutable and they are mostly used for the UI to show information. It doesn’t update its state, so once they have been created, they can’t be changed. In this type of widget, the build context is called only once.&lt;/p&gt;

&lt;p&gt;The way I understood stateless widgets was that I thought of them as building blocks, and we all know building blocks. Once a building block has been stacked on top of another, it can’t be changed unless it is destroyed and stacked again, but this time differently. &lt;/p&gt;

&lt;p&gt;When the portion of the user interface we are describing is independent of any other widgets, stateless widgets can be helpful. The widget types text, icons, icon buttons, and raised buttons are examples of stateless widgets.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stateful widget
&lt;/h3&gt;

&lt;p&gt;Well, these widgets are different from the stateless widgets. They are dynamic in the way that they can change their state repeatedly and that they can be redrawn again at any time.&lt;/p&gt;

&lt;p&gt;Stateful widgets can be combined, and the state of the widget can be tracked using a state object. The state object keeps track of variables such as the configuration of the widgets and the properties of the widget; these variables in the widget can be changed using a setstate, which then updates the app.&lt;/p&gt;

&lt;p&gt;The state object lives longer, so it has more lifecycle methods. Just as humans pass through different stages of life and die, so do stateful widgets, but one of the difference is we could tap into those stages in the widget if we wanted different things to happen at various times. This is  like going into a certain stage in your life and making a few changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Widget lifecycle methods
&lt;/h2&gt;

&lt;p&gt;The methods are listed to show what happens to a widget from the time it is created to the time it is discarded.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;initState&lt;/li&gt;
&lt;li&gt;Build &lt;/li&gt;
&lt;li&gt;didChangeDependencies&lt;/li&gt;
&lt;li&gt;didUpdateWidget&lt;/li&gt;
&lt;li&gt;setState&lt;/li&gt;
&lt;li&gt;deactivate&lt;/li&gt;
&lt;li&gt;Dispose&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  initState
&lt;/h3&gt;

&lt;p&gt;This is the first method that is called when we create a stateful widget and it is inserted into the widget tree. This method can be used to control HTTP queries, subscribe to streams, or any other object that we know will change the widget's data.&lt;/p&gt;

&lt;p&gt;The syntax looks like this;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@override
 void initState() {
//TODO: implement initState
   super.initState();
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From the documentation, the super.initState should be at the beginning of the call.&lt;/p&gt;

&lt;h3&gt;
  
  
  Build
&lt;/h3&gt;

&lt;p&gt;This is the second point in the lifecycle and this method is called after the init state, It describes the area of the user interface that the widget is meant to represent, and it can be called in different situations, like calling initState. calling didUpdateWidget. receiving a call to setState or when the dependency of the state object changes, it can also used for calling deactivate and then reinserting the state object into the tree at another location.&lt;/p&gt;

&lt;p&gt;The syntax looks like this;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@override
 Widget build(BuildContext context) {
   return Scaffold();
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  didChangeDependencies
&lt;/h3&gt;

&lt;p&gt;This comes after the initState in the lifecycle, and it will be triggered if a widget's dependent object changes.&lt;/p&gt;

&lt;p&gt;The build method is always called after this method and the framework would call this method to inform it of the change, and it can be called multiple times.&lt;/p&gt;

&lt;p&gt;The syntax like this;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@override
 void didChangeDependencies() {
//TODO: implement didChangeDependencies
   super.didChangeDependencies();
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The documentation doesn’t state whether the call should come after or before the super.didChangeDependencies&lt;/p&gt;

&lt;h3&gt;
  
  
  didUpdateWidget
&lt;/h3&gt;

&lt;p&gt;The didUpdateWidget is called if the parent widget needs to rebuild the widget because it changed its configuration. An example is when a variable is passed down the constructor and then the variable is updated. The framework provides the old widget as a comparison point between it and the new widget.The build() method will then be called by Flutter and If you need to compare the new widget to the previous one, use this method.&lt;/p&gt;

&lt;p&gt;Any additional calls to setState after using this method are unnecessary because Flutter always calls build().&lt;/p&gt;

&lt;p&gt;The syntax looks like this;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@override
void didUpdateWidget(ProductSquare oldWidget) {
//TODO: implement didUpdateWidget
   super.didUpdateWidget(oldWidget);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The documentation states that the super.didUpdateWidget should also be at the beginning of the call &lt;/p&gt;

&lt;h3&gt;
  
  
  deactivate
&lt;/h3&gt;

&lt;p&gt;This method is called when the widget is removed from the widget tree, but it can be reinserted before the current frame’s changes are finished, when the state is moved from one point in a tree to another.&lt;/p&gt;

&lt;p&gt;This should not be mistaken for the dispose method, as the deactivate method can remove a widget and insert it later in the widget tree, but the dispose method removes it entirely.&lt;/p&gt;

&lt;p&gt;The syntax looks like this;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@override
 void deactivate() {
//TODO: implement deactivate
   super.deactivate();
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;According to the documentation, the super.deactivate comes after the call&lt;/p&gt;

&lt;h3&gt;
  
  
  Dispose
&lt;/h3&gt;

&lt;p&gt;Dispose method is called when the state object has been removed entirely from the tree. It is like the opposite of initState; you can cancel all animations, streams, etc. with this method.&lt;/p&gt;

&lt;p&gt;This function is called when an object is permanently removed from a tree. You should set all of your dispose logic here. This function is called by the framework when this state object won't ever be rebuilt. The State object is regarded as unmounted and the mounted attribute is false when the framework calls dispose.&lt;/p&gt;

&lt;p&gt;The syntax looks like this;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@override
 void dispose() {
//TODO: implement dispose
   super.dispose();
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the same as the deactivate where the super.dispose comes last. &lt;/p&gt;

&lt;h2&gt;
  
  
  NOTABLE MENTIONS
&lt;/h2&gt;

&lt;h3&gt;
  
  
  constructor
&lt;/h3&gt;

&lt;p&gt;During the creation of a stateful widget, Flutter executes the constructor function and then calls the createState() method. When we examine the stateful widget, the constructor function is executed first. But the lifecycle of the stateful widget's State object begins with the call to the createState() method.&lt;/p&gt;

&lt;h3&gt;
  
  
  create
&lt;/h3&gt;

&lt;p&gt;The Framework instantly calls createState when told to build a StatefulWidget () and State objects are created with this method. All the mutable state for this widget is contained in this object. A StatefulWidget must use this method, although this step is not designated as an actual stage in the lifecycle, it is crucial to understand what is occurring behind the scenes.&lt;/p&gt;

&lt;p&gt;The syntax looks like this;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MyHomePage extends StatefulWidget {
 @override
 _MyHomePageState createState() =&amp;gt; _MyHomePageState();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The difference between stateless and stateful
&lt;/h2&gt;

&lt;p&gt;The stateless widget only updates when it is initialized while the stateless widget changes dynamically, RaisedButtons, Text, icons and can be implemented in the stateless widget, checkboxes, radio buttons, and sliders can be implemented in the stateful widget.&lt;/p&gt;

&lt;p&gt;Stateless widget does not have a setState(). It will be rendered once and will not update itself but stateful widget has an internal setState() and can re-render if the input data changes, stateless widget is a Static widget while stateful widgets are dynamic, the stateless widget can’t update during runtime, that isn’t the case for the stateless widget as it can update during runtime based on user action&lt;/p&gt;

&lt;h2&gt;
  
  
  CONCLUSION
&lt;/h2&gt;

&lt;p&gt;This topic has been one of the frequently asked questions by recruiters during job interviews and In this article, we have looked at the different lifecycles in a flutter widget and explained them. You can also try to use these methods in building your applications and In your flutter project, I hope this article gives you enough information about the widget lifecycle.&lt;/p&gt;

&lt;p&gt;We are going to look into flutter widgets more in our future articles and try to explain them in digestible chunks for you to understand.&lt;br&gt;
If there’s any thing I missed or you feel should be added to this article please do well to leave a comment below. Thanks for reading.😊&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>flutter</category>
      <category>beginners</category>
      <category>mobile</category>
    </item>
    <item>
      <title>How To Use Flutter Packages In Your Flutter Project</title>
      <dc:creator>emjaycodes</dc:creator>
      <pubDate>Sat, 23 Jul 2022 19:45:25 +0000</pubDate>
      <link>https://dev.to/emjaycodes/how-to-use-flutter-packages-in-your-flutter-project-p6c</link>
      <guid>https://dev.to/emjaycodes/how-to-use-flutter-packages-in-your-flutter-project-p6c</guid>
      <description>&lt;p&gt;Have you ever wanted to implement a certain functionality in your flutter code but got stuck because you didn’t know how to go about it? Well this is where flutter packages come in as they help to facilitate the building of your applications.&lt;br&gt;
Packages contributed by other developers to the Flutter and Dart ecosystem are referred to as Flutter packages. This allows quickly building an app without having to develop everything from scratch according to the flutter docs. In other words, they are just open source libraries of code that other people have created which you can import into your project with ease.&lt;/p&gt;

&lt;p&gt;Using Flutter Packages in Your Project&lt;br&gt;
There are a few steps you need to take to be able to use these packages:&lt;/p&gt;
&lt;h2&gt;
  
  
  STEP 1:
&lt;/h2&gt;

&lt;p&gt;You need to know the type of package you want to use in your project either by the specific name or by  similar keywords. Then go to &lt;a href="https://pub.dev/packages" rel="noopener noreferrer"&gt;https://pub.dev/packages&lt;/a&gt; where you’ll see varieties of packages for different problems.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F0kaesi33vpn6fdadd4en.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F0kaesi33vpn6fdadd4en.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We score packages from 1 to 100 so we can choose the most efficient one. While there may be many packages, you should look for those with the best ratings.&lt;br&gt;
For our example we’ll be using english_words by filiph.net.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fas38uld2yljmsl47qi9e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fas38uld2yljmsl47qi9e.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A few terms to familiarize yourself with when browsing these packages:&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;LIKES: *&lt;/em&gt; Likes offer a measure of how many developers have liked a package&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PUB POINTS:&lt;/strong&gt; A new way to measure quality. This includes several dimensions of quality such as code style, platform support, and maintainability. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Popularity:&lt;/strong&gt; This provides insight into what other developers are using by determining the number of developers who use a package.&lt;/p&gt;
&lt;h2&gt;
  
  
  STEP 2:
&lt;/h2&gt;

&lt;p&gt;Clicking on the ‘installing’ tab on the page shows you how to use the package. Firstly, we depend on it by adding just two lines to our pubspec.yaml file: &lt;br&gt;
dependencies: english_words: ^4.0.0&lt;br&gt;
Note: We have to be really careful about the Indentation in the pubspec.yaml file so that we don’t end up messing it up.&lt;/p&gt;

&lt;p&gt;Secondly, we can also add it to our project by running a command on the terminal.&lt;br&gt;
 flutter pub add english_words.&lt;br&gt;
And this will automatically add the package to the pubspec.yaml file. You’ll be notified that the pubspec.yaml file has been edited and you need to run a flutter pub get command.&lt;/p&gt;
&lt;h2&gt;
  
  
  STEP 3:
&lt;/h2&gt;

&lt;p&gt;Now in our code, we can import the package into our Main.dart file by adding it to the top of the file (the desired file) you want the package to be called in.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:english_words/english_words.dart';
Let’s take a little example 
import 'package:english_words/english_words.dart';
main() {
  nouns.take(50).forEach(print);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code above will print the top 50 most used nouns in the English language.&lt;/p&gt;

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

&lt;p&gt;It's done! You have successfully added a flutter package into your project. &lt;br&gt;
If you have any questions or concerns, feel free to contact the package developers through their email addresses listed on the package pages.&lt;/p&gt;

&lt;p&gt;You can also help the flutterdev community by creating your own package if one doesn't exist yet.&lt;/p&gt;

&lt;p&gt;Thanks.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>discuss</category>
      <category>react</category>
    </item>
    <item>
      <title>The simplest way to implement a dark mode feature in a flutter application</title>
      <dc:creator>emjaycodes</dc:creator>
      <pubDate>Sat, 23 Jul 2022 19:09:00 +0000</pubDate>
      <link>https://dev.to/emjaycodes/the-simplest-way-to-implement-a-dark-mode-feature-in-a-flutter-application-37lm</link>
      <guid>https://dev.to/emjaycodes/the-simplest-way-to-implement-a-dark-mode-feature-in-a-flutter-application-37lm</guid>
      <description>&lt;p&gt;Nowadays, the dark mode feature has become everyone’s default go-to display setting due to many reasons; like its ability to prolong the battery life of a device, reduce eye strain, and increase visibility for people with low vision who are sensitive to bright light.&lt;/p&gt;

&lt;p&gt;Hence, it is essential for applications to give it's users a choice on their display theme. In this article, we are going to learn the easiest way to add the dark mode feature to a flutter app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisite
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Basic knowledge of dart&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Basic knowledge of flutter&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We are going to be making use of two useful built-in classes of flutter which are; ValueNotifier and valueListenableBuilder.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  valueNotifier:
&lt;/h3&gt;

&lt;p&gt;A valueNotifier is &lt;a href="https://api.flutter.dev/flutter/foundation/ChangeNotifier-class.html" rel="noopener noreferrer"&gt;changeNotifier&lt;/a&gt; that holds just a single value which notifiers the widget that listens when the initial value has been changed. This value can be of any type and this helps in improving the performance of the app by rebuilding only the widget where the change needs to be applied.&lt;/p&gt;

&lt;h3&gt;
  
  
  valueListenableBuilder:
&lt;/h3&gt;

&lt;p&gt;A valueListenableBuilder as the name implies is a widget that is always attached to a valueListenable and lt checks to see if the valueNotifier value has changed and then builds the new widget accordingly. Think of a feature that's used throughout your app, and you'd like your app to update whenever or wherever that feature changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementing a Dark Mode Feature
&lt;/h2&gt;

&lt;p&gt;Let's get started on implementing the dark mode feature, we are going to create a new flutter app, the name of the app can be of your choice but for the purpose of this article, we will be naming our app dark_theme.&lt;/p&gt;

&lt;h2&gt;
  
  
  Main.dart file
&lt;/h2&gt;

&lt;p&gt;The main.dart file is where our material app is going to be built and in the material app we are going to highlight of some of these properties : &lt;strong&gt;ValueNotifier&lt;/strong&gt;, &lt;strong&gt;ValueListenableBuilder&lt;/strong&gt;, &lt;strong&gt;ThemeMode&lt;/strong&gt;, &lt;strong&gt;DarkTheme&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is how the code for the main.dart will look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:flutter/material.dart';
import 'firstscreen.dart';



void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  // Using "static" so that we can easily access it later
  static final ValueNotifier&amp;lt;ThemeMode&amp;gt; themeNotifier = ValueNotifier(ThemeMode.light);

  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ValueListenableBuilder&amp;lt;ThemeMode&amp;gt;(valueListenable: themeNotifier,
        builder: (_, ThemeMode currentMode, __) {
          return MaterialApp(
            // Remove the debug banner
            debugShowCheckedModeBanner: false,
            title: 'Dark Mode',
            theme: ThemeData(primarySwatch: Colors.purple),
            darkTheme: ThemeData.dark(),
            themeMode: currentMode,
            home:  const FirstScreen(),
          );
        });
  }  //MaterialApp
}  //ValueListenerBuilder
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;In the above piece of code :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;valueNotifier&lt;/strong&gt; has the ThemeMode property with the variable name as ThemeNotifier which is set to the default light mode.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;ValueListenerBuilder&lt;/strong&gt; also has the ThemeMode property with a ValueNotifier that listens specifically to the ThemeNotifier to check if the value of the ThemeNotifier has changed and then notifies the builder if the value has changed, to rebuild the widget&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;ThemeMode&lt;/strong&gt; is going to determine the mode of the application if the Theme(which includes the ThemeMode.system and the ThemeMode.light) and darkTheme are available.&lt;br&gt;
I added a little tweak to our ThemeData to change the look from our conventional blue color to purple color. You can also play around with the colors and find the one that suits your mode.&lt;/p&gt;
&lt;h2&gt;
  
  
  firstscreen.dart file
&lt;/h2&gt;

&lt;p&gt;We are going to create another file called firstscreen to show us how buttons reacts to the change in themes and the colors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This is what the code for the first screen looks like:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:dark_theme/secondscreen.dart';
import 'package:flutter/material.dart';
import 'main.dart';



class FirstScreen extends StatelessWidget {
  const FirstScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Theme app'),
        actions: [
          IconButton(
              icon: Icon(MyApp.themeNotifier.value == ThemeMode.light
                  ? Icons.dark_mode
                  : Icons.light_mode),
              onPressed: () {
                MyApp.themeNotifier.value =
                    MyApp.themeNotifier.value == ThemeMode.light
                        ? ThemeMode.dark
                        : ThemeMode.light;
              })
        ],
      ),
      body: Center(

      child: SizedBox(
        width: 300,
        height: 100,
        child: ElevatedButton(
          style: ElevatedButton.styleFrom(
             shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15))
          ),
          child:  const Text('Go to second Screen',
          style: TextStyle(fontSize: 20),
          ),
          onPressed: () {
            Navigator.push(context,
                MaterialPageRoute(builder: (context) =&amp;gt; const SecondScreen()));
          },
        ),
      ),


      ),
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In all the chunks of code above, what we are going to look at is the iconButton material widget which houses our icons and our ternary operator.&lt;br&gt;
Now in the iconButton widget, we are going to have a ternary operation that includes two icons, one for the darkTheme and one for the lightTheme which are icons.dark_mode and icons.light_mode respectively and in the ternary operation, we are going to say if the themeNotifier value is set to thememode.light then the icons.light_mode icon should be rendered on the UI of the application else render the icons.dark_mode icon.&lt;/p&gt;

&lt;p&gt;Now after that has been done we go to the onPressed property where we have another tenary operation which simply says when the iconsButton is pressed if the themeNotifier value is equal to the themeMode.light change to themeMode.dark else change the theme to ThemeMode.light&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;OUTPUT&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fkg6kxl9eiujs3p2kve3c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fkg6kxl9eiujs3p2kve3c.png" alt="this is the output for the first screen"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  secondscreen.dart file
&lt;/h2&gt;

&lt;p&gt;Let's create another file called Secondscreen to show how the text will react to the changes and a better view of the UI layout.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This is the code for the Second screen:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:flutter/material.dart';


class SecondScreen extends StatelessWidget {
  const SecondScreen ({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('second Screen'),
      ),
      body: const Center(
        child: Text(
          'Hello',
          style: TextStyle(fontSize: 50),
        ),
      ),
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;OUTPUT&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fzoq9i9imrkqqren0plsy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fzoq9i9imrkqqren0plsy.png" alt="this is the output for the second screen"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;congratulations we have gotten to the end of the article, we are going to do a little rundown on what we've discussed, we learned about value notifier and how it holds a single value, we talked about ValueLIstenableBuilder widget and how it listens to check if the value in the valueNotifier has changed and rebuilds the specific widget attached to it. we also saw how to use the valueNotifier and valueLIstenableBuilder in this application and that we could customize our themeData to fit our various applications if the given ones like the lightTheme does not suit us. Using the iconButton we were able to change the icons accordingly and we set what happens when the iconButton is pressed using a ternary operation.&lt;/p&gt;

&lt;p&gt;Please do well to leave a comment and share this article to help others understand how to use the feature in their project, thanks.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>beginners</category>
      <category>android</category>
    </item>
  </channel>
</rss>
