<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Chikezirim Orioha on Medium]]></title>
        <description><![CDATA[Stories by Chikezirim Orioha on Medium]]></description>
        <link>https://medium.com/@oriohac?source=rss-bb7a8c9b98b3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eWhjCbZhfbHhDqURU9-zHQ.jpeg</url>
            <title>Stories by Chikezirim Orioha on Medium</title>
            <link>https://medium.com/@oriohac?source=rss-bb7a8c9b98b3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 11:11:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@oriohac/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Scrape or Buy Amazon Product Data: A Cost-of-Ownership Framework]]></title>
            <link>https://medium.com/@oriohac/scrape-or-buy-amazon-product-data-a-cost-of-ownership-framework-00e02231ffce?source=rss-bb7a8c9b98b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/00e02231ffce</guid>
            <category><![CDATA[amazon-product]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[amazon-product-data-api]]></category>
            <category><![CDATA[bright-data]]></category>
            <category><![CDATA[amazon]]></category>
            <dc:creator><![CDATA[Chikezirim Orioha]]></dc:creator>
            <pubDate>Fri, 27 Nov 2026 06:46:28 GMT</pubDate>
            <atom:updated>2026-11-27T06:47:44.824Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7bZDh6vFwoflBFU2r6vnag.png" /></figure><h3>Scrape or Buy Amazon Product Data: A Cost-of-Ownership Framework</h3><p>Buy an Amazon dataset when you need a large, one-time or scheduled snapshot of products, prices, reviews or sellers and you don’t want to run anti-bot infrastructure. Scrape it yourself when you need custom fields, minute-level freshness on a small set of ASINs, or pages no vendor covers. Bright Data is the default pick for the buy route. Its <a href="https://get.brightdata.com/9vg58">Amazon datasets</a> hold 1.6B+ records across products, reviews, sellers and pricing, start at $250 per 100K records, and offer free sample downloads. For a middle path, its <a href="https://get.brightdata.com/g838gb">Amazon Scraper API</a> returns structured records from $0.75 per 1K records, and the free tier gives 5,000 credits a month. Keepa and Rainforest API suit narrower jobs like price history or live lookups.</p><h3>Should I scrape Amazon product data or buy a dataset?</h3><p>There are three routes, and most projects fit one of them cleanly.</p><ul><li><strong>Buy a dataset.</strong> You want a big slice of the catalog (a category, a brand, a marketplace) delivered as files. You’d rather write analysis code than fight CAPTCHAs. Market sizing, pricing research, model training and catalog enrichment all fit here.</li><li><strong>Call a scraper API.</strong> You have a list of ASINs or search URLs and want structured JSON back on demand. You pay per record and skip the unblocking work, but you still own the job scheduling.</li><li><strong>Build your own scraper.</strong> You need fields no vendor schema carries, or you’re polling a short list of ASINs far more often than any dataset refreshes.</li></ul><p>Bright Data covers the first two routes with one account: datasets from $250 per 100K records, and the Scraper API from $0.75 per 1K records.</p><h3>What is an Amazon dataset, and what fields does it contain?</h3><p>An Amazon dataset is a set of pre-collected, cleaned and validated records about Amazon listings. It is a snapshot of listings as they looked at collection time. Someone else already did the crawling, parsing and deduplication, and you receive the output.</p><p>Typical entities are products, reviews, sellers, pricing and bestseller rankings. A product record usually carries the ASIN, title, brand, category path, price, rating and review count, images, and Best Sellers Rank (BSR). Bright Data’s Amazon collection covers products, reviews, sellers and pricing, with 1.6B+ records.</p><p>Formats and delivery are the practical details. Bright Data datasets come as JSON, NDJSON, CSV or Parquet. They can be delivered to Snowflake, Amazon S3, Google Cloud, Azure, SFTP or a webhook. Parquet into S3 or Snowflake is the usual choice for analytics teams, since you can query it without a parsing step.</p><p>Freshness depends on how you buy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wQ-Jm35r-4T7NPv1ieXTOg.png" /></figure><p>A purchased dataset is only as fresh as its last delivery. If you need today’s Buy Box price, you need a scraper API or your own scraper.</p><h3>What does scraping Amazon yourself actually cost?</h3><p>Most of the cost is engineer time. Use this formula and plug in your own numbers:</p><pre>C_diy = (H_build + H_maint) x R  +  C_proxy  +  C_unblock  +  C_infra  +  C_rerun<br><br>H_build  = engineer hours to write the crawler and parsers<br>H_maint  = engineer hours per period on fixes, monitoring, on-call<br>R        = loaded hourly rate of the engineer<br>C_proxy  = pages fetched x average page weight (GB) x price per GB<br>C_unblock= pages fetched x price per request, if you use an unblocking API<br>C_infra  = headless browsers, queues, storage, logging<br>C_rerun  = cost of re-fetching after a parser breaks on a layout change</pre><p>Two reference inputs from Bright Data’s infrastructure help anchor the proxy and unblocking terms. Residential proxies start at $2.5/GB. Web Unlocker starts at $1 per 1K requests and charges per successful result, so retries on blocked fetches don’t add to the bill.</p><p>The line items people forget:</p><ul><li><strong>Proxies.</strong> Residential IPs are the usual choice for Amazon, and you pay for bandwidth, including failed fetches.</li><li><strong>CAPTCHA and fingerprint handling.</strong> Plain HTTP clients get challenged quickly. Playwright or another headless browser helps but adds compute and memory cost.</li><li><strong>Parser maintenance.</strong> Scrapy spiders and CSS selectors rot. Layout experiments change markup without warning.</li><li><strong>Storage and monitoring.</strong> You need alerts for silent failures, such as a field that suddenly comes back empty.</li><li><strong>On-call time.</strong> Someone has to own it when a Monday refresh returns half the rows.</li></ul><p>The failure modes I see most often are these:</p><ol><li><strong>Variant ASINs.</strong> A parent ASIN fans out into child ASINs with different prices, sizes and availability. A parser that grabs the page’s main price quietly mixes variants.</li><li><strong>Regional pricing.</strong> Price and availability change with delivery ZIP code. Without a location set per request, you get inconsistent numbers that look valid.</li><li><strong>Lazy-loaded reviews.</strong> Review blocks load after the initial HTML, and pagination for the full set needs extra requests or a rendered browser session.</li></ol><p>Amazon’s rate limiting and CAPTCHA challenges are the main source of failures in practice. Rotating residential IPs, realistic browser fingerprints and modest concurrency per IP all help. An unblocking API handles the same problems on its side.</p><h3>Scrape-or-Buy Decision Matrix: which route fits your project?</h3><p>Here is how the three routes compare on the five factors that decide most projects, plus the shape of the bill.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c7EjJKvhOBMJ6wdYBDzehQ.png" /></figure><p>The honest limit: DIY wins on custom fields and sub-hourly refresh for a small ASIN list. Nothing else on this table matches it there.</p><p>Treat these as decision rules:</p><ul><li>If you need the same large slice of the catalog once, or on a schedule, buy the dataset.</li><li>If you need records for a specific ASIN list when you ask for them, call the scraper API.</li><li>If you need fewer than 5,000 records a month, the free tier covers you at one credit per record, so don’t build anything yet.</li><li>If a field you need is in no vendor schema, scrape it yourself or use Scraper Studio.</li><li>If you need both history and a live feed, split the job. Buy the bulk and fetch only the changes.</li></ul><h3>How much does it cost to get 1 million Amazon records?</h3><p>Here is the arithmetic at the published starting prices, at 100K, 1M and 10M records.</p><p><strong>Dataset route.</strong> At $250 per 100K records, 1M records is 10 × $250 = <strong>$2,500</strong>.</p><p><strong>Scraper API route.</strong> At $0.75 per 1K records, 1M records is 1,000 × $0.75 = <strong>$750</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZLi5_fDaQrCzaV7F0thD5Q.png" /></figure><p>The last column assumes one successful fetch per record at $1 per 1K requests. It is raw unblocking only, with no parsing, no engineer and no storage.</p><p>Three things stand out:</p><ol><li><strong>The scraper API is cheaper per record than a one-time dataset at starting prices.</strong> A dataset costs more per record, but you aren’t running jobs, handling failures or tracking which ASINs came back.</li><li><strong>Refresh discounts reverse the comparison. </strong>A monthly refresh at 80% off works out to $50 per 100K records, or $500 per 1M. That is below the scraper API’s $750 per 1M. If you need the same large slice refreshed regularly, the dataset is the cheaper route.</li><li><strong>DIY starts behind.</strong> Fetching 1M pages through Web Unlocker is $1,000 before you pay anyone to write a parser. That already exceeds the $750 scraper API figure, so no engineer-hour count makes DIY cheaper on cost at that volume. With residential proxies, the same $750 buys 300 GB at $2.5/GB. If your average fetched page across 1M requests weighs more than 0.3 MB, proxy bandwidth alone passes the scraper API price.</li></ol><p>For the DIY side, use this break-even formula:</p><pre>H* = (C_buy - C_proxy - C_unblock - C_infra) / R</pre><p>If H* is negative, DIY can’t win on cost at that volume. If H* is positive, it is the number of total engineer hours, build plus maintenance over the period, that you can spend before buying becomes cheaper.</p><h3>Which Amazon data providers should I compare?</h3><p>Bright Data covers both the dataset and scraper API routes. The others are narrower, and each is better than a bulk dataset in at least one way.</p><h4>Bright Data</h4><figure><img alt="Bright Data homepage · November 19, 2026" src="https://cdn-images-1.medium.com/max/1024/0*ma7Nbj7IiSjNDLdh" /><figcaption>Bright Data homepage · November 19, 2026</figcaption></figure><p>Bright Data is the strongest all-round choice when you want volume. The Amazon datasets hold 1.6B+ records across products, reviews, sellers and pricing, and start at $250 per 100K records, with free samples. The Amazon Scraper API starts at $0.75 per 1K records. Scraper Studio builds a custom scraper from a plain-language prompt and repairs itself when the site changes. The MCP Server is free for agent lookups. Where others fit better: Keepa for price history charts, and Rainforest or Oxylabs if you want a pure per-ASIN API without a bulk file option.</p><h4>Keepa</h4><figure><img alt="Keepa homepage · November 19, 2026" src="https://cdn-images-1.medium.com/max/1024/0*s_ojjgj9HtBlxrd3" /><figcaption>Keepa homepage · November 19, 2026</figcaption></figure><p><a href="https://keepa.com/">Keepa</a> is a price and sales-rank tracker with an API behind it, so it is neither a bulk dataset nor a page scraper. It is the best fit for price history charts and for sales-rank history. Amazon doesn’t publish unit sales, so BSR over time is the standard proxy for product sales. Keepa gives you that history without you collecting it. It is less suited to fields outside what it tracks, such as review text, or to pulling a full category catalog as a file.</p><h4>Rainforest API</h4><figure><img alt="Rainforest API homepage · November 19, 2026" src="https://cdn-images-1.medium.com/max/1024/0*0tB2okVJ65hsACdU" /><figcaption>Rainforest API homepage · November 19, 2026</figcaption></figure><p><a href="https://www.rainforestapi.com/">Rainforest API</a>, from Traject Data, is a live, structured product-page API for per-ASIN lookups. It supports the US, UK, DE, FR, CA, IN and other marketplaces, returns JSON or CSV, and can push results by webhook or to your storage. Plans run from Hobbyist at $23/month for 500 credits and Starter at $83/month for 10,000 credits, up to Production at $375/month for 250,000 credits and BigData at $1,000/month for 1,000,000 credits, all billed annually. Custom ZIP or postal codes are included per plan (1 on Starter, 3 on Production, 5 on BigData), which helps with the regional pricing problem. What it lacks next to a dataset is a ready-made bulk snapshot. You supply the list and pay per call.</p><h4>Oxylabs</h4><figure><img alt="Oxylabs homepage · November 19, 2026" src="https://cdn-images-1.medium.com/max/1024/0*HFEBTb4Cc3NsBTBa" /><figcaption>Oxylabs homepage · November 19, 2026</figcaption></figure><p><a href="https://oxylabs.io/">Oxylabs</a> offers a Web Scraper API with an Amazon target and sells datasets as a separate product. Its Amazon non-JS scraping starts at $0.50 per 1K results on the smaller tiers and falls to $0.25 per 1K results at the highest volume tier, which is below the $0.75 per 1K records starting price of the Bright Data scraper API route. Plans start at $15/month, and new accounts get $5 in welcome credits. If raw per-result price is your deciding factor, Oxylabs deserves a quote comparison.</p><h4>DataForSEO</h4><figure><img alt="DataForSEO homepage · November 19, 2026" src="https://cdn-images-1.medium.com/max/1024/0*7CYcshi_1kW2ePwe" /><figcaption>DataForSEO homepage · November 19, 2026</figcaption></figure><p><a href="https://dataforseo.com/">DataForSEO</a> sells Amazon product and merchant data through its Merchant API and an Amazon database, plus Amazon intelligence in its Labs API. Billing is pay-as-you-go with no subscription, a $50 minimum top-up, a balance that never expires and a $1 trial credit. That suits small or irregular jobs better than a dataset purchase. Standard mode is cheaper and queued, and Live mode returns immediately at a higher price. Its strength is search and marketing data, so expect Amazon coverage shaped around rankings and listings.</p><h4>Grepsr</h4><figure><img alt="Grepsr homepage · November 19, 2026" src="https://cdn-images-1.medium.com/max/1024/0*vnjRb_Zgoq8e9qat" /><figcaption>Grepsr homepage · November 19, 2026</figcaption></figure><p><a href="https://www.grepsr.com/">Grepsr</a> is a managed extraction service. You describe the fields, and its team designs and runs the pipelines and delivers clean data. That makes it better than a bulk dataset when your schema is unusual and nobody on your side wants to own scrapers. Delivery formats include CSV, JSON and Parquet, to S3, Google Cloud, Azure and other destinations, on hourly, daily, weekly or monthly schedules. It holds ISO 27001:2022 and SOC 2 Type II certifications. What it lacks is a sample-and-download catalog: you scope a project first, so the first rows arrive later than with a standard dataset.</p><h3>Can I get Amazon’s official data through an API instead?</h3><p>Yes, but the official APIs cover a different job from market data.</p><ul><li><strong>Selling Partner API (SP-API).</strong> It is for authorized sellers and vendors who manage their own catalog, pricing, inventory and orders. It tells you about your business, and its access model is built around your seller account.</li><li><strong>Creators API.</strong> It replaces PA-API 5 and targets affiliate use, such as showing products and links on content sites.</li></ul><p>Neither one gives you bulk competitor data. You can’t export a rival brand’s catalog, review text or seller list through them. Neither exposes user-item interaction histories either.</p><p>For the last case, collaborative filtering and recommender research, the usual source is the public <a href="https://amazon-reviews-2023.github.io/">Amazon Reviews datasets</a> built for that research. They link user IDs, item IDs, ratings and timestamps, which is the shape those models need. Purchase histories aren’t public, so no vendor can sell them. A purchased reviews dataset gives you reviews per product, which is a different structure from a user-item matrix.</p><h3>When should I still build my own Amazon scraper?</h3><p>Build your own when one of these is true:</p><ul><li><strong>You need custom fields no vendor schema includes</strong>, such as a specific badge, a delivery-promise line for a particular ZIP code, or a field from a page type nobody extracts.</li><li><strong>You need sub-hourly freshness on a small ASIN list.</strong> Polling a few hundred listings every few minutes is where DIY beats datasets and per-record APIs.</li><li><strong>You’re learning or prototyping.</strong> If the goal is to learn Playwright or Scrapy, build it.</li></ul><p>The hybrid pattern covers the rest. Buy the historical bulk dataset once, then scrape or call a scraper API only for the live delta, such as new ASINs, price changes and fresh reviews. You pay the dataset rate for the heavy lifting and per-record rates for the small stream of changes.</p><h3>How do I go from decision to first rows in a day?</h3><p>This is the buy-and-API workflow, sample first:</p><ol><li><strong>Download a free sample.</strong> Open it and inspect the schema. Check that your fields exist, that variants are represented the way you expect, and that IDs join to your own data.</li><li><strong>Filter before buying.</strong> Narrow by category, brand, marketplace or date so you pay only for the slice you need.</li><li><strong>Choose delivery.</strong> Pick a format (Parquet or NDJSON for pipelines, CSV for spreadsheets) and a destination such as S3, Snowflake, Google Cloud, Azure, SFTP or a webhook.</li><li><strong>Pick a refresh cadence.</strong> Match it to how fast your fields go stale, since scheduled refreshes are discounted against a one-time purchase.</li><li><strong>Fill gaps with the Scraper API or Scraper Studio.</strong> Use the Amazon Scraper API for ASINs missing from the dataset, using the 5,000 free monthly credits to test. Use Scraper Studio when you need a field the pre-built scraper doesn’t return.</li></ol><p>If you’re building an agent that needs an occasional live lookup, the Bright Data MCP Server is free and returns markdown and JSON, so you can skip writing request code for those cases.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=00e02231ffce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create Live-streaming app in Flutter using Zegocloud live streaming Kit]]></title>
            <link>https://medium.com/@oriohac/how-to-create-live-streaming-app-in-flutter-using-zegocloud-live-streaming-kit-650354f5eff3?source=rss-bb7a8c9b98b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/650354f5eff3</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[live-streaming]]></category>
            <category><![CDATA[live-streaming-app]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <dc:creator><![CDATA[Chikezirim Orioha]]></dc:creator>
            <pubDate>Sat, 13 Dec 2025 05:34:17 GMT</pubDate>
            <atom:updated>2025-12-13T05:34:17.494Z</atom:updated>
            <content:encoded><![CDATA[<p>Live streaming has become an integral part of our communication, ranging from its use in education for e-learning, to its use in the entertainment industry for gaming, comedy, podcasts and also in sports industry for live sporting activities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5kZgyp4isAUwy_NS_hNWTQ.png" /></figure><p>The importance of live streaming cannot be overemphasized, but creating reliable platforms or applications to carry out this important functionality may be challenging and tough most times.</p><p><a href="https://www.zegocloud.com/">Zegocloud</a> has provided an easy way to get a live streaming app working in a cross-platform environment within the shortest possible time, and with few lines of codes, made possible by the <a href="https://www.zegocloud.com/docs/uikit/live-streaming-kit-flutter/overview">Zegocloud Live Streaming Kit</a>.</p><p><strong>Prerequisites</strong></p><p>Some things are needed to be put in place before the live streaming can be up and running. A <a href="https://console.zegocloud.com/">Zegocloud console account</a>, flutter installed on your computer and basic programming knowledge.</p><p><strong>Getting Started</strong></p><p>To get started, a new flutter project will be created, by heading into your project’s directory and typing in the following command in the terminal of in the same directory.</p><pre>flutter create project_name</pre><p>Once you have created the project, scroll down to the pubspec.yaml file and add the following dependencies to the dependencies section of the file.</p><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br><br>  cupertino_icons: ^1.0.8<br>  flutter_dotenv: ^6.0.0<br>  zego_uikit: ^2.28.23<br>  zego_uikit_signaling_plugin: ^2.8.15<br>  zego_uikit_prebuilt_live_streaming: ^3.15.2</pre><p>Once you have all these in the file, run the following command to download the dependencies and make them ready to be used in your project.</p><pre>flutter pub get</pre><p><strong>Building the App</strong></p><p>Now that you have gotten your project ready, you need to head to your Zegocloud console to create a Live Streaming app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RnZH4RfGdatm_tQ2_nWSiQ.png" /></figure><p>Once you have created that, get your AppID and AppSign credentials, which are necessary for the creation of this project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eP89M78_r68vcsePZp2EMg.png" /></figure><p>Head to your flutter project and open the lib folder, in the lib folder, there are some files which will be created, the first being the entry point of the app, the main.dart file.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:zego_stream/home.dart&#39;;<br><br>void main() {<br>  runApp(const ZegoStream());<br>}<br><br>class ZegoStream extends StatelessWidget {<br>  const ZegoStream({super.key});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      title: &#39;Zego Stream&#39;,<br>      home: Home(),<br>    );<br>  }<br>}</pre><p>When the application is started, we are led to the home page. This home page has two buttons, “Host a Live Stream” button and “Watch a Live Stream” button. When the “Host a Live Stream” button is clicked, we are sent to a page called LiveStreamingPage with a boolean isHost parameter, which is true, when you’re hosting a live stream, and when the “Watch a Live Stream” button is clicked, the isHost is false. Below is the complete code of the home page.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:zego_stream/live_streaming_page.dart&#39;;<br><br>class Home extends StatelessWidget {<br>  const Home({super.key});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      body: Center(<br>        child: Padding(<br>          padding: const EdgeInsets.all(16.0),<br>          child: Column(<br>            mainAxisAlignment: MainAxisAlignment.center,<br>            children: [<br>              InkWell(<br>                onTap: () {<br>                  Navigator.push(<br>                    context,<br>                    MaterialPageRoute(<br>                      builder: (context) =&gt; LiveStreamingPage(isHost: true),<br>                    ),<br>                  );<br>                },<br>                child: Container(<br>                  padding: EdgeInsets.symmetric(vertical: 8, horizontal: 12),<br>                  width: double.infinity,<br>                  decoration: BoxDecoration(<br>                    color: Colors.blue,<br>                    borderRadius: BorderRadius.circular(12),<br>                  ),<br>                  child: Center(<br>                    child: Text(<br>                      &quot;Host a Live Stream&quot;,<br>                      style: TextStyle(<br>                        fontWeight: FontWeight.bold,<br>                        color: Colors.white,<br>                      ),<br>                    ),<br>                  ),<br>                ),<br>              ),<br>              SizedBox(height: 16),<br>              InkWell(<br>                onTap: () {<br>                  Navigator.push(<br>                    context,<br>                    MaterialPageRoute(<br>                      builder: (context) =&gt; LiveStreamingPage(isHost: false),<br>                    ),<br>                  );<br>                },<br>                child: Container(<br>                  padding: EdgeInsets.symmetric(vertical: 8, horizontal: 12),<br>                  width: double.infinity,<br>                  decoration: BoxDecoration(<br>                    color: Colors.blue,<br>                    borderRadius: BorderRadius.circular(12),<br>                  ),<br>                  child: Center(<br>                    child: Text(<br>                      &quot;Watch a Live Stream&quot;,<br>                      style: TextStyle(<br>                        fontWeight: FontWeight.bold,<br>                        color: Colors.white,<br>                      ),<br>                    ),<br>                  ),<br>                ),<br>              ),<br>            ],<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>The LiveStreamingPage implements the ZegoUIKitPrebuiltLiveStreaming(), where the AppID, AppSign, userID and username are supplied. An important parameter in the ZegoUIKitPrebuiltLiveStreaming() is the ‘config’ parameter, which takes either ZegoUIKitPrebuiltLiveStreamingConfig.host() or ZegoUIKitPrebuiltLiveStreamingConfig.audience() to determine when a user is the host of the live stream and give them host privileges or whether the user joined the livestream.</p><pre>import &#39;dart:math&#39;;<br><br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:zego_stream/config.dart&#39;;<br>import &#39;package:zego_uikit_prebuilt_live_streaming/zego_uikit_prebuilt_live_streaming.dart&#39;;<br><br>class LiveStreamingPage extends StatelessWidget {<br>    final String? liveID;<br>  final bool isHost;<br>  const LiveStreamingPage({super.key, this.liveID, required this.isHost,});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    final String userID = Random().nextInt(1000).toString();<br>    return SafeArea(<br>      child: ZegoUIKitPrebuiltLiveStreaming(<br>              appID: AppConfig.appid,<br>              appSign: AppConfig.appsign,<br>              userID: userID,<br>              userName: &quot;user_$userID&quot;,<br>              liveID: &quot;liveIDtest&quot;,<br>              config: isHost ? ZegoUIKitPrebuiltLiveStreamingConfig.host()<br>              : ZegoUIKitPrebuiltLiveStreamingConfig.audience(),<br>          ),<br>    );<br>  }<br>}</pre><p>When we have gone through these few steps, our app is ready for live streaming, but we have to configure some platform dependencies.</p><p><strong>Configure your project for Android</strong></p><p>In the top level of your project folder, head to the android folder, then open the app build.gradle.kts file, and add the following.</p><ol><li>Add these to the dependencies android/app/build.gradle.kts</li></ol><pre>dependencies {<br>    // Introduce Firebase BoM (Bill of Materials)<br>    implementation(platform(&quot;com.google.firebase:firebase-bom:31.0.2&quot;))<br>// Firebase Analytics and Messaging (FCM)<br>    implementation(&quot;com.google.firebase:firebase-analytics&quot;)<br>    implementation(&quot;com.google.firebase:firebase-analytics&quot;)<br>    implementation(&quot;com.google.firebase:firebase-messaging&quot;)<br>    // ZPNs package for Google FCM push<br>    implementation(&quot;im.zego:zpns-fcm:2.8.0&quot;)<br>}</pre><p>2. change the ‘minSdk’</p><pre>minSdk = 23</pre><p>3. In the releases section, add the following for the proguard file which we will add later.</p><pre>release {<br>            proguardFiles(getDefaultProguardFile(&quot;proguard-android.txt&quot;),file(&quot;proguard-rules.pro&quot;))<br>        }</pre><p>4. Update your dependencies section to have the needed dependencies,.</p><pre>dependencies {<br>    // Introduce Firebase BoM (Bill of Materials)<br>    implementation(platform(&quot;com.google.firebase:firebase-bom:31.0.2&quot;))<br>// Firebase Messaging (FCM)<br>    implementation(&quot;com.google.firebase:firebase-messaging&quot;)<br>    // ZPNs package for Google FCM push<br>    implementation(&quot;im.zego:zpns-fcm:2.8.0&quot;)<br>}</pre><p>In the android folder, head into the settings.gradle.kts and implement these changes in the plugins section.</p><pre>plugins {<br>    id(&quot;dev.flutter.flutter-plugin-loader&quot;) version &quot;1.0.0&quot;<br>    id(&quot;com.android.application&quot;) version &quot;8.7.0&quot; apply false<br>    // START: FlutterFire Configuration<br>    id(&quot;com.google.gms.google-services&quot;) version(&quot;4.3.15&quot;) apply false<br>    // END: FlutterFire Configuration<br>    id(&quot;org.jetbrains.kotlin.android&quot;) version &quot;1.8.22&quot; apply false<br>}</pre><p>Head into the gradle/wrapper folder and make the distributionUrl to have gradle 8 &gt; in my case the below is what I have.</p><pre>distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip</pre><p>Modify permissions in the Android manifest file by going to /android/app/src/main/AndroidManifest.xml and putting the below permissions just after the manifest tag.</p><pre>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.ACCESS_WIFI_STATE&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.BLUETOOTH&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.RECORD_AUDIO&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.MODIFY_AUDIO_SETTINGS&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.CAMERA&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.WAKE_LOCK&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.VIBRATE&quot;/&gt;<br>&lt;uses-permission android:name=&quot;android.permission.ACCESS_NOTIFICATION_POLICY&quot;/&gt;<br>&lt;uses-permission android:name=&quot;android.permission.POST_NOTIFICATIONS&quot;/&gt;<br>&lt;!--for bring app to foreground from background in Android 10 --&gt;<br>&lt;uses-permission android:name=&quot;android.permission.SYSTEM_ALERT_WINDOW&quot; /&gt;</pre><p>To prevent code obfuscation, we create ‘proguard-rules.pro’ in the android/app/ folder.</p><pre>-keep class **.zego.** { *; }</pre><p>Configure your project for iOS</p><ol><li>Open the ios folder, head to the podfile and paste the following to the ‘post_install do |installer|’ section.</li></ol><pre># Start of the permission_handler configuration<br>target.build_configurations.each do |config|<br>  config.build_settings[&#39;GCC_PREPROCESSOR_DEFINITIONS&#39;] ||= [<br>    &#39;$(inherited)&#39;,<br>    &#39;PERMISSION_CAMERA=1&#39;,<br>    &#39;PERMISSION_MICROPHONE=1&#39;,<br>  ]<br>end<br># End of the permission_handler configuration</pre><p>2. In the iOS folder, open the Runner folder and update the ‘dict’ section of the info.plist file, ‘/ios/Runner/Info.plist’.</p><pre>&lt;key&gt;NSCameraUsageDescription&lt;/key&gt;<br>&lt;string&gt;We require camera access to connect&lt;/string&gt;<br>&lt;key&gt;NSMicrophoneUsageDescription&lt;/key&gt;<br>&lt;string&gt;We require microphone access to connect&lt;/string&gt;</pre><p>After we have gone through these processes, we are now ready to test our Live Streaming app. Go to your terminal and run, flutter run to test the app.</p><pre>flutter run</pre><p><strong>Final Output</strong></p><p>Below is the final output, showing a host and another user who joined as audience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jsk5OmVPNqdLAkRRuPaS1A.png" /></figure><p><strong>Conclusion</strong></p><p>We have seen how Zegocloud can help us build, customize and test live streaming applications with few lines of code, but also have the ability to configure this application to our taste. You can also <a href="https://youtu.be/y4CGAESMBUA">watch this guide</a>, if you prefer video to text.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=650354f5eff3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create a chat app in flutter using Zegocloud UIkit Chat API]]></title>
            <link>https://medium.com/@oriohac/how-to-create-a-chat-app-in-flutter-using-zegocloud-uikit-chat-api-3a478c42528f?source=rss-bb7a8c9b98b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a478c42528f</guid>
            <category><![CDATA[chat-app-development]]></category>
            <category><![CDATA[chat-apps]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <dc:creator><![CDATA[Chikezirim Orioha]]></dc:creator>
            <pubDate>Fri, 12 Dec 2025 03:51:43 GMT</pubDate>
            <atom:updated>2025-12-12T03:58:57.871Z</atom:updated>
            <content:encoded><![CDATA[<p>A chat application is one of the very important parts of software development, as this is needed in most projects as an integral part of the project or in standalone projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cEoJhBmiOrYao5S053P95Q.png" /></figure><p>The need for chat apps cannot be overemphasized, as they help in users communication, serves as a tool for easy transactions, and also helps in swift response to customers complaints.</p><p>Creating a chat application is not straightforward, it needs a lot of technicalities to be put in to achieve a fast, reliable and easy to use system. When developers want to build one, they need to have a good knowledge of creating frontend applications, handling the backend, managing the database and handling the instant response with tools like websockets.</p><p>The drawbacks listed above can be solved with <a href="https://www.zegocloud.com/">Zegocloud</a>, as they provide a rich and customizable <a href="https://www.zegocloud.com/docs/uikit/in-app-chat-kit-flutter/overview">In-app chat kit</a> that can help you build and test a chat app in the fastest possible time.</p><p><strong>Getting Started</strong></p><p>Before getting started, there are some prerequisite needed, which are; Zegocloud console account, Firebase account and Flutter installed on your computer.</p><p><strong>What is the In-app Chat Kit</strong></p><p>The Zegocloud In-app Chat Kit is a UI component library based on the <a href="https://docs.zegocloud.com/article/14543">In-app Chat SDK</a>. It helps us build chat features like one-on-one chat and group chats, as it provides these UI components. The UI kit helps us build in-app chat applications, customize them based on our needs, and eliminate the need for complex UI development.</p><p><strong>Configure push notifications</strong></p><p>To configure push notifications, so that a user can get notified when another user sends a message to him/her or to a group, we foloow these processes.</p><ol><li>Go to your firebase console and create a project, in the project, download the google-service.json file.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ySrhTjBl5dwu_Ino1Ty4RQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IyXKUr569IQs7oP_LC_y9A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*-y8UhY-fzSREXy8-PGM5fg.png" /></figure><p>2. Go to your project, in the project move to service management, and then activate the in-app chat by importing the google-services.json file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m-OcWr603eUqYZWjVbY6Sw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-DG0NZN6kxckAFaIUk8Ifw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5i0TaUa1r6F287l1xEMoFA.png" /></figure><p><strong>Implementation</strong></p><p>To get started, you have to create a flutter project. Go to your projects directory and enter the below command in your terminal.</p><pre>flutter create project_name</pre><p>After you have created the project, we will go ahead to import the needed dependencies for the project, this will be updated in our project’s pubspec.yaml file. In the dependencies section we update the below.</p><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br><br>  cupertino_icons: ^1.0.8<br>  flutter_dotenv: ^5.2.1<br>  firebase_core: ^4.0.0<br>  zego_zimkit: ^1.19.2</pre><p>Once you update that, download the dependencies by entering the flutter pub get command in your terminal.</p><pre>flutter pub get</pre><p>In the lib folder, you will create an interface folder, which will contain the login, home screen and a popup menu widget.</p><p>Let us explore the main.dart code, which is the starting point of the project.</p><pre>void main() async{<br>  WidgetsFlutterBinding.ensureInitialized();<br>  await dotenv.load(fileName: &quot;.env&quot;);<br>  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);<br><br>  ZIMKit().init(<br>    appID: AppConfig.appid, <br>    appSign: AppConfig.appsign,<br>    notificationConfig: ZegoZIMKitNotificationConfig(<br>      resourceID: &#39;zimkit_push&#39;,<br>      androidNotificationConfig: ZegoZIMKitAndroidNotificationConfig(<br>        channelID: &#39;Zim Message&#39;,<br>        channelName: &#39;Message&#39;,<br>        icon: &#39;@drawable/ic_launcher&#39;<br>      )<br>    )<br>    );<br>  runApp(ZegoChat(navigatorKey: navigatorKey));<br>}</pre><p>In the main method we ensure that our .env file where app secrets like appID is initialized once the app starts, then we also initialize Firebase.</p><p>Firebase is used in our app to create push notifications, so that when a user sends a message we get the notification, which leads us into the app.</p><p>Finally we wrap the runApp method in the ZIMKit().init(), where we update the parameters with the needed values.</p><p>Below is the full implementation of the main.dart.</p><pre>import &#39;package:firebase_core/firebase_core.dart&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:flutter_dotenv/flutter_dotenv.dart&#39;;<br>import &#39;package:zego_chat/config.dart&#39;;<br>import &#39;package:zego_chat/firebase_options.dart&#39;;<br>import &#39;package:zego_chat/interfaces/login.dart&#39;;<br>import &#39;package:zego_zimkit/zego_zimkit.dart&#39;;<br>final navigatorKey = GlobalKey&lt;NavigatorState&gt;();<br><br>void main() async{<br>  WidgetsFlutterBinding.ensureInitialized();<br>  await dotenv.load(fileName: &quot;.env&quot;);<br>  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);<br><br><br>  ZIMKit().init(<br>    appID: AppConfig.appid, <br>    appSign: AppConfig.appsign,<br>    notificationConfig: ZegoZIMKitNotificationConfig(<br>      resourceID: &#39;zimkit_push&#39;,<br>      androidNotificationConfig: ZegoZIMKitAndroidNotificationConfig(<br>        channelID: &#39;Zim Message&#39;,<br>        channelName: &#39;Message&#39;,<br>        icon: &#39;@drawable/ic_launcher&#39;<br>      )<br>    )<br>    );<br>  runApp(ZegoChat(navigatorKey: navigatorKey));<br>}<br><br>class ZegoChat extends StatelessWidget {<br>  final GlobalKey&lt;NavigatorState&gt; navigatorKey;<br>  const ZegoChat({super.key, required this.navigatorKey});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      title: &#39;Zego Chat App&#39;,<br>      debugShowCheckedModeBanner: false,<br>      theme: ThemeData(primarySwatch: Colors.blue),<br>      home: const Login(),<br>    );<br>  }<br>}</pre><p>Once the app loads we are taken to the login screen, in this example we will use a minimalist login screen. Here we have two text fields, the email and the name field. Once the two fields are filled, the proceed button is clicked and ZIMKit().connectUser() will be triggered with the user’s id and name entered through the text fields the user id then taken to the home screen.</p><pre>() async {<br>                          await ZIMKit().connectUser(<br>                            id: _emailController.text,<br>                            name: _usernameController.text,<br>                          );<br>                          Navigator.of(context).pushReplacement(<br>                            MaterialPageRoute(<br>                              builder: (context) =&gt; HomeScreen(),<br>                            ),<br>                          );<br>                        },</pre><p>Below is the full login screen implementation.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:zego_chat/interfaces/home_screen.dart&#39;;<br>import &#39;package:zego_zimkit/zego_zimkit.dart&#39;;<br><br>class Login extends StatefulWidget {<br>  const Login({super.key});<br><br>  @override<br>  State&lt;Login&gt; createState() =&gt; _LoginState();<br>}<br><br>class _LoginState extends State&lt;Login&gt; {<br>  final _emailController = TextEditingController();<br>  final _usernameController = TextEditingController();<br>  final bool _isLoading = false;<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(title: Text(&quot;Login&quot;)),<br>      body: Container(<br>        child: Padding(<br>          padding: const EdgeInsets.all(12.0),<br>          child: Center(<br>            child: Column(<br>              mainAxisAlignment: MainAxisAlignment.center,<br>              children: [<br>                TextField(<br>                  controller: _emailController,<br>                  keyboardType: TextInputType.emailAddress,<br>                  decoration: InputDecoration(<br>                    label: Text(&quot;Email&quot;),<br>                    hintText: &quot;example@email.com&quot;,<br>                    border: OutlineInputBorder(<br>                      borderRadius: BorderRadius.circular(8),<br>                      borderSide: BorderSide(color: Colors.blue),<br>                    ),<br>                  ),<br>                ),<br>                Container(height: 8),<br>                TextField(<br>                  controller: _usernameController,<br>                  keyboardType: TextInputType.text,<br>                  decoration: InputDecoration(<br>                    label: Text(&quot;Name&quot;),<br>                    hintText: &quot;Enter Your Name&quot;,<br>                    border: OutlineInputBorder(<br>                      borderRadius: BorderRadius.circular(8),<br>                      borderSide: BorderSide(color: Colors.blue),<br>                    ),<br>                  ),<br>                ),<br>                Container(height: 8),<br>                InkWell(<br>                  onTap: _isLoading<br>                      ? null<br>                      : () async {<br>                          await ZIMKit().connectUser(<br>                            id: _emailController.text,<br>                            name: _usernameController.text,<br>                          );<br>                          Navigator.of(context).pushReplacement(<br>                            MaterialPageRoute(<br>                              builder: (context) =&gt; HomeScreen(),<br>                            ),<br>                          );<br>                        },<br>                  child: Container(<br>                    height: 48,<br>                    width: double.maxFinite,<br>                    decoration: BoxDecoration(<br>                      borderRadius: BorderRadius.circular(12),<br>                      color: Colors.blue,<br>                    ),<br>                    child: Center(<br>                      child: _isLoading<br>                          ? CircularProgressIndicator(color: Colors.white)<br>                          : Text(<br>                              &quot;Procceed&quot;,<br>                              style: TextStyle(color: Colors.white),<br>                            ),<br>                    ),<br>                  ),<br>                ),<br>              ],<br>            ),<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>Finally we look through the home screen implementation. In here, we have the ZIMKitConversationListView, which lists the chat that are clickable, when clicked we are led into the exact chat, this is enabled by the ZIMKitMessageListPage with two parameters conversationID and conversationType.</p><pre>body: ZIMKitConversationListView(<br>          onPressed: (context, conversation, defaultAction) {<br>            Navigator.push(<br>              context,<br>              MaterialPageRoute(<br>                builder: (context) {<br>                  return ZIMKitMessageListPage(<br>                    conversationID: conversation.id,<br>                    conversationType: conversation.type,<br>                  );<br>                },<br>              ),<br>            );</pre><p>Below is the full implementation of the home screen.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:zego_chat/interfaces/widgets/pop_up_menu.dart&#39;;<br>import &#39;package:zego_zimkit/zego_zimkit.dart&#39;;<br><br>class HomeScreen extends StatelessWidget {<br>  const HomeScreen({super.key});<br>  @override<br>  Widget build(BuildContext context) {<br>    return WillPopScope(<br>      onWillPop: () async =&gt; false,<br>      child: Scaffold(<br>        appBar: AppBar(<br>          title: const Text(&#39;Chats&#39;),<br>          actions: const [PopUpMenu()],<br>        ),<br>        body: ZIMKitConversationListView(<br>          onPressed: (context, conversation, defaultAction) {<br>            Navigator.push(<br>              context,<br>              MaterialPageRoute(<br>                builder: (context) {<br>                  return ZIMKitMessageListPage(<br>                    conversationID: conversation.id,<br>                    conversationType: conversation.type,<br>                  );<br>                },<br>              ),<br>            );<br>          },<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>On the AppBar of the home screen, a pop-up menu is created, which helps create the type of chat that we need, either a group chat or one-on-one chat, and also to create or join a group chat, this is done by the help of these pop-up menu items.</p><pre>   PopupMenuItem(<br>            value: &quot;New Chat&quot;,<br>            child: ListTile(<br>              leading: Icon(Icons.chat_bubble),<br>              title: Text(&quot;New Chat&quot;, maxLines: 1),<br>            ),<br>            onTap: () =&gt; ZIMKit().showDefaultNewPeerChatDialog(context),<br>          ),<br>          PopupMenuItem(<br>            value: &quot;New Group&quot;,<br>            child: ListTile(<br>              leading: Icon(Icons.group),<br>              title: Text(&quot;New Group&quot;, maxLines: 1),<br>            ),<br>            onTap: () =&gt; ZIMKit().showDefaultNewGroupChatDialog(context),<br>          ),<br>          PopupMenuItem(<br>            value: &quot;Join Group&quot;,<br>            child: ListTile(<br>              leading: Icon(Icons.group_add),<br>              title: Text(&quot;Join Group&quot;, maxLines: 1),<br>            ),<br>            onTap: () =&gt; ZIMKit().showDefaultJoinGroupDialog(context),<br>          ),</pre><p>Below is the full code of the pop up menu.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:zego_zimkit/zego_zimkit.dart&#39;;<br><br>class PopUpMenu extends StatefulWidget {<br>  const PopUpMenu({super.key});<br><br>  @override<br>  State&lt;PopUpMenu&gt; createState() =&gt; _PopUpMenuState();<br>}<br><br>class _PopUpMenuState extends State&lt;PopUpMenu&gt; {<br>  final userId = TextEditingController();<br>  final userName = TextEditingController();<br>  final groupId = TextEditingController();<br>  final groupUserName = TextEditingController();<br>  @override<br>  Widget build(BuildContext context) {<br>    return PopupMenuButton(<br>      icon: Icon(Icons.more_vert_rounded),<br>      itemBuilder: (context) {<br>        return [<br>          PopupMenuItem(<br>            value: &quot;New Chat&quot;,<br>            child: ListTile(<br>              leading: Icon(Icons.chat_bubble),<br>              title: Text(&quot;New Chat&quot;, maxLines: 1),<br>            ),<br>            onTap: () =&gt; ZIMKit().showDefaultNewPeerChatDialog(context),<br>          ),<br>          PopupMenuItem(<br>            value: &quot;New Group&quot;,<br>            child: ListTile(<br>              leading: Icon(Icons.group),<br>              title: Text(&quot;New Group&quot;, maxLines: 1),<br>            ),<br>            onTap: () =&gt; ZIMKit().showDefaultNewGroupChatDialog(context),<br>          ),<br>          PopupMenuItem(<br>            value: &quot;Join Group&quot;,<br>            child: ListTile(<br>              leading: Icon(Icons.group_add),<br>              title: Text(&quot;Join Group&quot;, maxLines: 1),<br>            ),<br>            onTap: () =&gt; ZIMKit().showDefaultJoinGroupDialog(context),<br>          ),<br>        ];<br>      },<br>    );<br>  }<br>}</pre><p>Once we have all these in place, we now setup our project for Android and ios.</p><p><strong>Configure your project for Android</strong></p><p>In the top level of your project folder, head to the android folder, then open the app build.gradle.kts file, and add the following.</p><ol><li>Add these to the dependencies android/app/build.gradle.kts</li></ol><pre>dependencies {<br>    // Introduce Firebase BoM (Bill of Materials)<br>    implementation(platform(&quot;com.google.firebase:firebase-bom:31.0.2&quot;))<br>// Firebase Analytics and Messaging (FCM)<br>    implementation(&quot;com.google.firebase:firebase-analytics&quot;)<br>    implementation(&quot;com.google.firebase:firebase-analytics&quot;)<br>    implementation(&quot;com.google.firebase:firebase-messaging&quot;)<br>    // ZPNs package for Google FCM push<br>    implementation(&quot;im.zego:zpns-fcm:2.8.0&quot;)<br>}</pre><p>2. change the ‘minSdk’</p><pre>minSdk = 23</pre><p>3. In the releases section, add the following for the proguard file which we will add later.</p><pre>release {<br>            proguardFiles(getDefaultProguardFile(&quot;proguard-android.txt&quot;),file(&quot;proguard-rules.pro&quot;))<br>        }</pre><p>4. Update your dependencies section to have the needed dependencies,.</p><pre>dependencies {<br>    // Introduce Firebase BoM (Bill of Materials)<br>    implementation(platform(&quot;com.google.firebase:firebase-bom:31.0.2&quot;))<br>// Firebase Messaging (FCM)<br>    implementation(&quot;com.google.firebase:firebase-messaging&quot;)<br>    // ZPNs package for Google FCM push<br>    implementation(&quot;im.zego:zpns-fcm:2.8.0&quot;)<br>}</pre><p>In the android folder, head into the settings.gradle.kts and implement these changes in the plugins section.</p><pre>plugins {<br>    id(&quot;dev.flutter.flutter-plugin-loader&quot;) version &quot;1.0.0&quot;<br>    id(&quot;com.android.application&quot;) version &quot;8.7.0&quot; apply false<br>    // START: FlutterFire Configuration<br>    id(&quot;com.google.gms.google-services&quot;) version(&quot;4.3.15&quot;) apply false<br>    // END: FlutterFire Configuration<br>    id(&quot;org.jetbrains.kotlin.android&quot;) version &quot;1.8.22&quot; apply false<br>}</pre><p>Head into the gradle/wrapper folder and make the distributionUrl to have gradle 8 &gt; in my case the below is what I have.</p><pre>distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip</pre><p>Modify permissions in the Android manifest file by going to /android/app/src/main/AndroidManifest.xml and putting the below permissions just after the manifest tag.</p><pre>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.ACCESS_WIFI_STATE&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.BLUETOOTH&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.RECORD_AUDIO&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.MODIFY_AUDIO_SETTINGS&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.CAMERA&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.WAKE_LOCK&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.VIBRATE&quot;/&gt;<br>&lt;uses-permission android:name=&quot;android.permission.ACCESS_NOTIFICATION_POLICY&quot;/&gt;<br>&lt;uses-permission android:name=&quot;android.permission.POST_NOTIFICATIONS&quot;/&gt;<br>&lt;!--for bring app to foreground from background in Android 10 --&gt;<br>&lt;uses-permission android:name=&quot;android.permission.SYSTEM_ALERT_WINDOW&quot; /&gt;</pre><p>To prevent code obfuscation, we create ‘proguard-rules.pro’ in the android/app/ folder.</p><pre>-keep class **.zego.** { *; }</pre><p>Configure your project for iOS</p><ol><li>Open the ios folder, head to the podfile and paste the following to the ‘post_install do |installer|’ section.</li></ol><pre># Start of the permission_handler configuration<br>target.build_configurations.each do |config|<br>  config.build_settings[&#39;GCC_PREPROCESSOR_DEFINITIONS&#39;] ||= [<br>    &#39;$(inherited)&#39;,<br>    &#39;PERMISSION_CAMERA=1&#39;,<br>    &#39;PERMISSION_MICROPHONE=1&#39;,<br>  ]<br>end<br># End of the permission_handler configuration</pre><p>2. In the ios folder, open the Runner folder and update the ‘dict’ section of the info.plist file, ‘/ios/Runner/Info.plist’.</p><pre>&lt;key&gt;NSCameraUsageDescription&lt;/key&gt;<br>&lt;string&gt;We require camera access to connect&lt;/string&gt;<br>&lt;key&gt;NSMicrophoneUsageDescription&lt;/key&gt;<br>&lt;string&gt;We require microphone access to connect&lt;/string&gt;</pre><p>After you have followed these steps, we are now ready to test our one-on-one and group chat app. Go to your terminal and run, flutter run to test the app.</p><pre>flutter run</pre><p><strong>Final Output</strong></p><p>The final output is seen below, as you can send a one-on-one message, create or join a group chat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/331/1*QjBFgFXKA4xRUoqlIef9xA.png" /></figure><p><strong>Conclusion</strong></p><p>Zegocloud has helped us to build a chat application in the shortest possible time, and also afforded us the ease not to write complex codes, while maintaining the ability of customization in the app, where the Zegocloud in-app chat kit has helped us to handle the business logic and also provided the UI to what would have taken a lot of time to achieve.</p><p>If you prefer to follow this guide with a video, <a href="https://youtu.be/gv-N-qnC4dA">you can get that here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a478c42528f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to implement voice and video call features in your flutter app with Zegocloud]]></title>
            <link>https://medium.com/@oriohac/how-to-implement-voice-and-video-call-features-in-your-flutter-app-with-zegocloud-ac8a17530c32?source=rss-bb7a8c9b98b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac8a17530c32</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[voice-calling-app]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <dc:creator><![CDATA[Chikezirim Orioha]]></dc:creator>
            <pubDate>Fri, 12 Dec 2025 03:36:10 GMT</pubDate>
            <atom:updated>2025-12-12T03:58:12.616Z</atom:updated>
            <content:encoded><![CDATA[<p>Creating an app that can communicate across the two major mobile Operating Systems can be a tough task as you need to have good knowledge of the programming languages needed to create apps for iOS and Android, which is Swift and Kotlin(or Java), respectively. Also, implementing voice and video call features on these platforms takes some time and technicality to implement, that is why I am going to show you how to implement voice and video call features in your app using Dart cross-platform framework, Flutter, and <a href="https://www.zegocloud.com/">Zegocloud</a> voice and video call UIKit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JYFKvCaOKBvp2rwc-A2E0Q.jpeg" /></figure><p><strong>ZEGOCLOUD</strong></p><p>You may be wondering what Zegocloud is, or the what they offer, the answer is right here. Zegocloud helps to provide real-time SDKs and UIKits for easy integration of voice, video, chat, and live-streaming features into our apps.</p><p>Zegocloud gives you 10000 free minutes when you sign up on the platform.</p><p><strong>UIKit</strong></p><p>The Zegocloud <a href="https://www.zegocloud.com/uikits">UIKits</a> are feature rich pre-built UI components which are easily customizable to whatever you have in mind to build, combining the business logic and its UI to give developers the ability to build these features in the shortest possible time.</p><p><strong>Prerequisites</strong></p><p>For us to get started, there are some prerequisites which are needed to successfully implement these features in our app.</p><ol><li>Good programming knowledge</li><li>A computer with minimum of 8gb RAM and 20gb Storage space</li><li>Have Flutter installed in your computer</li><li>Create a Zegocloud account</li><li>And a firebase account</li></ol><p><strong>Getting Started</strong></p><p>For us to get started I will walk you through on how to create a Zegocloud account, as you will use the credentials gotten in your dashboard to implement the application.</p><p>We will start by heading over to <a href="https://console.zegocloud.com/account/signup">Zegocloud</a>’s account creation section, and create our account by filling the fields in the form.</p><figure><img alt="Zegocloud signup screen." src="https://cdn-images-1.medium.com/max/1024/1*fJnVrFdBV5oZ_hllUeMXwA.png" /></figure><p>When you have successfully signed in, you will have some actions to take on your dashboard, what we need next is to create a project. We will create a project by clicking on create your project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AdTH9JgjMS9MsdPi5qmIBw.png" /></figure><p>On the next screen you will see forms of projects you can create, ranging from voice and video calls to live-streaming. Then, select the preferred choice and click next to proceed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I4Z9vDuObQPqiVBOEG_15g.png" /></figure><p>In the next screen select an appropriate name for your app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n9q9jCbr6aASN0tGnDotBg.png" /></figure><p>Then choose whether you want to develop with a UIkit or SDK</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZquNm1oOTRzecdrkoEPoag.png" /></figure><p>Once that is done, you have successfully created your project, which will be seen on the list of projects in the project management page, then you are ready to integrate this on your flutter application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z1p4XTRggIRO_pQ97cIM9A.png" /></figure><p>One more step that is important you have to take is to click into the created project and look through the details of the project. There are two important credentials needed for your project which are the AppID and AppSign, note them down, because they’ll be used later on to achieve our aim to implement voice and video call feature in our apps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0oUNkNuL67uS2eVyoNpSHw.png" /></figure><p><strong>Firebase</strong></p><p>Firebase will help us store user data and also help us send push notifications to users when needed. We will not go deep into the usage of Firebase in this tutorial, you can go to <a href="https://firebase.google.com/">Firebase</a> and find out more on how to get started with the <a href="https://console.firebase.google.com/">Firebase console</a>.</p><p><strong>Flutter Configuration</strong></p><p>To get started with Flutter, we have to create a new Flutter project by going to our projects directory, or any location of our choice which we have access to on our computer, and open up any terminal of our choice and type out this command.</p><pre>flutter create your_app_name</pre><p>When you have successfully created the project, you will see your project files generated for you.</p><p>On the top level of the project folder open up the pubspec.yaml<em> </em>file, here we import the dependencies needed for our project. We will need dependencies for the Zegocloud UIKit, Firebase and for env file which willl help us hide our secrets and not expose them when we upload our code to version control systems like gitHub. Here is how our dependencies section will look.</p><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br><br>  <br>  cupertino_icons: ^1.0.8<br>  zego_uikit_prebuilt_call: ^4.16.29<br>  firebase_core: ^3.13.0<br>  firebase_auth: ^5.5.3<br>  cloud_firestore: ^5.6.7<br>  zego_uikit_signaling_plugin: ^2.8.12<br>  flutter_dotenv: ^5.2.1</pre><p>Once you have put all these in your pubspec.yaml page, you enter the below command in your terminal which is opened on your flutter project’s directory to get your dependencies.</p><pre>flutter pub get</pre><p>The first folder we will go to is the lib folder, where we will create three folders, the interface folder, which will hold the home page, the login, signup pages and other widgets. The next folder is the model, which will hold user details, then the service folder, which holds the files that controls our communication with Firebase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ncGy5fEaO4JrtIOch5G0Lw.png" /></figure><p>The top level of the lib folder contains our main.dart file which is the starting point of our app. Below is the code for the main file.</p><pre>import &#39;package:firebase_auth/firebase_auth.dart&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:flutter_dotenv/flutter_dotenv.dart&#39;;<br>import &#39;package:zego/config.dart&#39;;<br>import &#39;package:zego/interfaces/home.dart&#39;;<br>import &#39;package:zego/interfaces/login.dart&#39;;<br>import &#39;package:zego_uikit_prebuilt_call/zego_uikit_prebuilt_call.dart&#39;;<br>import &#39;package:firebase_core/firebase_core.dart&#39;;<br>import &#39;package:zego_uikit_signaling_plugin/zego_uikit_signaling_plugin.dart&#39;;<br>import &#39;firebase_options.dart&#39;;<br><br>final navigatorKey = GlobalKey&lt;NavigatorState&gt;();<br>Future&lt;void&gt; main() async {<br>  WidgetsFlutterBinding.ensureInitialized();<br>  await dotenv.load();<br>  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);<br><br><br>  ZegoUIKitPrebuiltCallInvitationService().setNavigatorKey(navigatorKey);<br><br><br>  final user = FirebaseAuth.instance.currentUser;<br>  final userID = user?.uid ?? &quot;userID&quot;;<br>  final userName = user?.email ?? &quot;User&quot;;<br><br>  ZegoUIKitPrebuiltCallInvitationService().init(<br>    appID: AppConfig.appid,<br>    appSign: AppConfig.appsign,<br>    userID: userID,<br>    userName: userName,<br>    plugins: [ZegoUIKitSignalingPlugin()],<br>  );<br>  runApp(MyApp(navigatorKey: navigatorKey));<br>}<br><br>class MyApp extends StatelessWidget {<br>  final GlobalKey&lt;NavigatorState&gt; navigatorKey;<br>  const MyApp({super.key, required this.navigatorKey});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      navigatorKey: navigatorKey,<br>      title: &#39;Zego App&#39;,<br>      home: StayIn(),<br>    );<br>  }<br>}</pre><p>The home parameter in the MaterialApp which is the default route of the app, has a class StayIn() passed to it, this class helps to check whether the user has signed in to the app recently and keep their session alive, thereby the user doesn’t have to login every time they come to the app, the class is seen below.</p><pre>class StayIn extends StatelessWidget {<br>  const StayIn({super.key});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return StreamBuilder&lt;User?&gt;(<br>      stream: FirebaseAuth.instance.authStateChanges(),<br>      builder: (context, snapshot) {<br>        if (snapshot.connectionState != ConnectionState.active) {<br>          return Center(<br>            child: Text(<br>              &quot;Zego&quot;,<br>              style: TextStyle(fontWeight: FontWeight.bold, fontSize: 58),<br>            ),<br>          );<br>        }<br>        final user = snapshot.data;<br>        return user == null ? Login() : Home(firebaseUser: user);<br>      },<br>    );<br>  }<br>}</pre><p>Also, on the top level of the lib folder we have the config.dart file, which helps us to read the secrets in the .env file placed in the project’s folder.</p><pre>import &#39;package:flutter_dotenv/flutter_dotenv.dart&#39;;<br><br>class AppConfig {<br>  static int get appid =&gt; int.tryParse(dotenv.env[&#39;appID&#39;] ?? &#39;&#39;) ?? 0;<br>  static String get appsign =&gt; dotenv.env[&#39;appSign&#39;] ?? &#39;&#39;;<br>}</pre><p>The next thing we do is to create the service.dart file, which we talked about earlier on, that will handle our communication with Firebase.</p><pre>import &#39;package:firebase_auth/firebase_auth.dart&#39;;<br>import &#39;package:cloud_firestore/cloud_firestore.dart&#39;;<br>import &#39;package:zego/model/usermodel.dart&#39;;<br><br>class FirebaseService {<br>  final FirebaseAuth _auth = FirebaseAuth.instance;<br>  final FirebaseFirestore _firestore = FirebaseFirestore.instance;<br><br>  //create new user on firebase with some added user data<br>  Future&lt;UserModel?&gt; signUp({<br>    required String name,<br>    required String email,<br>    required String username,<br>    required String password,<br>  }) async {<br>    try {<br>      UserCredential result = await _auth.createUserWithEmailAndPassword(<br>        email: email,<br>        password: password,<br>      );<br><br>      final User user = result.user!;<br>      UserModel newUser = UserModel(<br>        uid: user.uid,<br>        name: name,<br>        email: email,<br>        username: username,<br>      );<br><br>      // Make user data saved in Firestore<br>      await _firestore.collection(&#39;users&#39;).doc(user.uid).set(newUser.toMap());<br><br>      return newUser;<br>    } catch (e) {<br>      print(&#39;Failed to Signup: $e&#39;);<br>      return null;<br>    }<br>  }<br><br>  // login user with the password and email option<br>  Future&lt;UserModel?&gt; login({<br>    required String email,<br>    required String password,<br>  }) async {<br>    try {<br>      UserCredential result = await _auth.signInWithEmailAndPassword(<br>        email: email,<br>        password: password,<br>      );<br><br>      final User user = result.user!;<br><br>      // Get user data from Firestore<br>      DocumentSnapshot doc =<br>          await _firestore.collection(&#39;users&#39;).doc(user.uid).get();<br><br>      if (doc.exists) {<br>      // user data matches? return data.<br>        return UserModel.fromMap(doc.data() as Map&lt;String, dynamic&gt;);<br>      } else {<br>        print(&#39;User data not found in Firestore.&#39;);<br>        return null;<br>      }<br>    } catch (e) {<br>      print(&#39;Login Error: $e&#39;);<br>      return null;<br>    }<br>  }<br><br> <br>  Future&lt;void&gt; signOut() async {<br>    await _auth.signOut();<br>  }<br><br>  <br><br>  Future&lt;List&lt;UserModel&gt;&gt; getAllUsersExceptCurrent() async {<br>    final currentUid = _auth.currentUser!.uid;<br>    final querySnapshot = await _firestore.collection(&#39;users&#39;).get();<br><br>    return querySnapshot.docs<br>        .where((doc) =&gt; doc.id != currentUid)<br>        .map((doc) =&gt; UserModel.fromMap(doc.data()))<br>        .toList();<br>  }<br>}</pre><p>We create our user model to match the requirements needed for our app, which needs a uid as and a special identifier like an email.</p><pre>class UserModel {<br>  final String uid;<br>  final String name;<br>  final String email;<br>  final String username;<br><br>  UserModel({<br>    required this.uid,<br>    required this.name,<br>    required this.email,<br>    required this.username,<br>  });<br><br>  Map&lt;String, dynamic&gt; toMap() {<br>    return {<br>      &#39;uid&#39;: uid,<br>      &#39;name&#39;: name,<br>      &#39;email&#39;: email,<br>      &#39;username&#39;: username,<br>    };<br>  }<br><br>  factory UserModel.fromMap(Map&lt;String, dynamic&gt; map) {<br>    return UserModel(<br>      uid: map[&#39;uid&#39;] ?? &#39;&#39;,<br>      name: map[&#39;name&#39;] ?? &#39;&#39;,<br>      email: map[&#39;email&#39;] ?? &#39;&#39;,<br>      username: map[&#39;username&#39;] ?? &#39;&#39;,<br>    );<br>  }<br>}</pre><p>The next page what we will create is the signup page, which will have four fields of name, username, email, and password. When the registration is successful, the user is sent to the login page, which we will also create.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:zego/interfaces/login.dart&#39;;<br>import &#39;package:zego/services/service.dart&#39;;<br><br>class Signup extends StatefulWidget {<br>  const Signup({super.key});<br><br>  @override<br>  State&lt;Signup&gt; createState() =&gt; _SignupState();<br>}<br><br>class _SignupState extends State&lt;Signup&gt; {<br>  final _nameController = TextEditingController();<br>  final _usernameController = TextEditingController();<br>  final _emailController = TextEditingController();<br>  final _passwordController = TextEditingController();<br>  final FirebaseService _firebaseService = FirebaseService();<br><br>  bool _isLoading = false;<br><br>  void _handleSignup() async {<br>    setState(() =&gt; _isLoading = true);<br><br>    final name = _nameController.text.trim();<br>    final username = _usernameController.text.trim();<br>    final email = _emailController.text.trim();<br>    final password = _passwordController.text.trim();<br><br>    final user = await _firebaseService.signUp(<br>      name: name,<br>      email: email,<br>      username: username,<br>      password: password,<br>    );<br><br>    setState(() =&gt; _isLoading = false);<br><br>    if (user != null) {<br>      ScaffoldMessenger.of(context).showSnackBar(<br>        SnackBar(content: Text(&#39;Signup successful!&#39;)),<br>      );<br>      Navigator.pushReplacement(<br>        context,<br>        MaterialPageRoute(builder: (_) =&gt; const Login()),<br>      );<br>    } else {<br>      ScaffoldMessenger.of(context).showSnackBar(<br>        SnackBar(content: Text(&#39;Signup failed!&#39;)),<br>      );<br>    }<br>  }<br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(title: Text(&quot;Signup&quot;)),<br>      body: Container(<br>        child: Padding(<br>          padding: const EdgeInsets.all(12.0),<br>          child: Center(<br>            child: Column(<br>              mainAxisAlignment: MainAxisAlignment.center,<br>              children: [<br>                 TextField(<br>                  controller: _nameController,<br>                  keyboardType: TextInputType.name,<br>                  decoration: InputDecoration(<br>                    label: Text(&quot;Name&quot;),<br>                    hintText: &quot;Ful Name&quot;,<br>                    border: OutlineInputBorder(borderRadius: BorderRadius.circular(8),borderSide: BorderSide(color: Colors.blue)),<br>                  ),<br>                ),<br>                Container(height: 8),<br>                TextField(<br>                  controller: _usernameController,<br>                  keyboardType: TextInputType.name,<br>                  decoration: InputDecoration(<br>                    label: Text(&quot;Username&quot;),<br>                    hintText: &quot;Username&quot;,<br>                    border: OutlineInputBorder(borderRadius: BorderRadius.circular(8),borderSide: BorderSide(color: Colors.blue)),<br>                  ),<br>                ),<br>                Container(height: 8),<br>                TextField(<br>                  controller: _emailController,<br>                  keyboardType: TextInputType.emailAddress,<br>                  decoration: InputDecoration(<br>                    label: Text(&quot;Email&quot;),<br>                    hintText: &quot;example@email.com&quot;,<br>                    border: OutlineInputBorder(borderRadius: BorderRadius.circular(8),borderSide: BorderSide(color: Colors.blue)),<br>                  ),<br>                ),<br>                Container(height: 8),<br>                TextField(<br>                  controller: _passwordController,<br>                  keyboardType: TextInputType.visiblePassword,<br>                  obscureText: true,<br>                  decoration: InputDecoration(<br>                    label: Text(&quot;Password&quot;),<br>                    hintText: &quot;Password&quot;,<br>                    border: OutlineInputBorder(borderRadius: BorderRadius.circular(8),borderSide: BorderSide(color: Colors.blue)),<br>                  ),<br>                ),<br>                Container(height: 8),<br>                InkWell(<br>                  onTap: _isLoading ? null : _handleSignup,<br>                  child: Container(<br>                    height: 48,<br>                    width: double.maxFinite,<br>                    decoration: BoxDecoration(<br>                      borderRadius: BorderRadius.circular(12),<br>                      color: Colors.blue,<br>                    ),<br>                    child: Center(<br>                      child: _isLoading<br>                      ? CircularProgressIndicator(color: Colors.white,)<br>                      : Text(<br>                        &quot;Signup&quot;,<br>                        style: TextStyle(color: Colors.white),<br>                      ),<br>                    ),<br>                  ),<br>                ),<br>                Container(height: 12),<br>                Row(<br>                  children: [<br>                    Text(&quot;Already have an account? &quot;),<br>                    InkWell(<br>                      onTap: () {<br>                        Navigator.pushReplacement(<br>                          context,<br>                          MaterialPageRoute&lt;void&gt;(<br>                            builder: (BuildContext context) =&gt; const Login(),<br>                          ),<br>                        );<br>                      },<br>                      child: Text(<br>                        &quot;Login&quot;,<br>                        style: TextStyle(color: Colors.blue),<br>                      ),<br>                    ),<br>                  ],<br>                ),<br>              ],<br>            ),<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>Then the login page will have two fields of email and password, as seen below.</p><pre>import &#39;package:firebase_auth/firebase_auth.dart&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:zego/interfaces/home.dart&#39;;<br>import &#39;package:zego/interfaces/signup.dart&#39;;<br>import &#39;package:zego/services/service.dart&#39;;<br><br>class Login extends StatefulWidget {<br>  const Login({super.key});<br><br>  @override<br>  State&lt;Login&gt; createState() =&gt; _LoginState();<br>}<br><br>class _LoginState extends State&lt;Login&gt; {<br>  final _emailController = TextEditingController();<br>  final _passwordController = TextEditingController();<br>  final FirebaseService _firebaseService = FirebaseService();<br><br>  bool _isLoading = false;<br><br>  void _handleLogin() async {<br>    setState(() =&gt; _isLoading = true);<br><br>    final email = _emailController.text.trim();<br>    final password = _passwordController.text.trim();<br><br>    final user = await _firebaseService.login(email: email, password: password);<br><br>    setState(() =&gt; _isLoading = false);<br><br>    if (user != null) {<br>      final firebaseUser = FirebaseAuth.instance.currentUser;<br>      if (firebaseUser != null) {<br>        ScaffoldMessenger.of(context).showSnackBar(<br>          SnackBar(content: Text(&#39;Login successful! Welcome, ${user.name}&#39;)),<br>        );<br>        // Navigate to home screen<br>        Navigator.pushReplacement(<br>          context,<br>          MaterialPageRoute(<br>            builder: (context) =&gt; Home(firebaseUser: firebaseUser),<br>          ),<br>        );<br>      } else {<br>        ScaffoldMessenger.of(<br>          context,<br>        ).showSnackBar(SnackBar(content: Text(&#39;Login failed!&#39;)));<br>      }<br>    }<br>  }<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(title: Text(&quot;Login&quot;)),<br>      body: Container(<br>        child: Padding(<br>          padding: const EdgeInsets.all(12.0),<br>          child: Center(<br>            child: Column(<br>              mainAxisAlignment: MainAxisAlignment.center,<br>              children: [<br>                TextField(<br>                  controller: _emailController,<br>                  keyboardType: TextInputType.emailAddress,<br>                  decoration: InputDecoration(<br>                    label: Text(&quot;Email&quot;),<br>                    hintText: &quot;example@email.com&quot;,<br>                    border: OutlineInputBorder(<br>                      borderRadius: BorderRadius.circular(8),<br>                      borderSide: BorderSide(color: Colors.blue),<br>                    ),<br>                  ),<br>                ),<br>                Container(height: 8),<br>                TextField(<br>                  controller: _passwordController,<br>                  keyboardType: TextInputType.visiblePassword,<br>                  obscureText: true,<br>                  decoration: InputDecoration(<br>                    label: Text(&quot;Password&quot;),<br>                    hintText: &quot;Password&quot;,<br>                    border: OutlineInputBorder(<br>                      borderRadius: BorderRadius.circular(8),<br>                      borderSide: BorderSide(color: Colors.blue),<br>                    ),<br>                  ),<br>                ),<br>                Container(height: 8),<br>                InkWell(<br>                  onTap: _isLoading ? null : _handleLogin,<br>                  child: Container(<br>                    height: 48,<br>                    width: double.maxFinite,<br>                    decoration: BoxDecoration(<br>                      borderRadius: BorderRadius.circular(12),<br>                      color: Colors.blue,<br>                    ),<br>                    child: Center(<br>                      child:<br>                          _isLoading<br>                              ? CircularProgressIndicator(color: Colors.white)<br>                              : Text(<br>                                &quot;Login&quot;,<br>                                style: TextStyle(color: Colors.white),<br>                              ),<br>                    ),<br>                  ),<br>                ),<br>                Container(height: 12),<br>                Row(<br>                  children: [<br>                    Text(&quot;Don&#39;t have an account? &quot;),<br>                    InkWell(<br>                      onTap: () {<br>                        Navigator.pushReplacement(<br>                          context,<br>                          MaterialPageRoute&lt;void&gt;(<br>                            builder: (BuildContext context) =&gt; const Signup(),<br>                          ),<br>                        );<br>                      },<br>                      child: Text(<br>                        &quot;Signup&quot;,<br>                        style: TextStyle(color: Colors.blue),<br>                      ),<br>                    ),<br>                  ],<br>                ),<br>              ],<br>            ),<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>Once we login, we will be sent to the home screen, in this screen, we will fire up the ZegoUIKitPrebuiltCallInvitationService which we will place in the home.dart initState(), in there we will also put a function which will get users except the current user, making it look like a phone contacts page.</p><pre>  @override<br>  void initState() {<br>    super.initState();<br>    _usersFuture = _service.getAllUsersExceptCurrent();<br><br>    ZegoUIKitPrebuiltCallInvitationService().init(<br>      appID: AppConfig.appid,<br>      appSign: AppConfig.appsign,<br>      userID: widget.firebaseUser.uid,<br>      userName: widget.firebaseUser.displayName ?? widget.firebaseUser.email!,<br>      plugins: [ZegoUIKitSignalingPlugin()],<br>    );<br>  }</pre><p>In the body of the Scaffold(), we will show an error message when there’s error, then, show a message that show no other user has registered, if there is no other user yet, then show the users as a list if there are registered users and no error, below is the full home screen page code.</p><pre>import &#39;package:firebase_auth/firebase_auth.dart&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:zego/config.dart&#39;;<br>import &#39;package:zego/interfaces/widgets/user_call_widget.dart&#39;;<br>import &#39;package:zego/model/usermodel.dart&#39;;<br>import &#39;package:zego/services/service.dart&#39;;<br>import &#39;package:zego_uikit_prebuilt_call/zego_uikit_prebuilt_call.dart&#39;;<br>import &#39;package:zego_uikit_signaling_plugin/zego_uikit_signaling_plugin.dart&#39;;<br><br>class Home extends StatefulWidget {<br>  final User firebaseUser;<br>  const Home({super.key, required this.firebaseUser});<br><br>  @override<br>  State&lt;Home&gt; createState() =&gt; _HomeState();<br>}<br><br>class _HomeState extends State&lt;Home&gt; {<br>  final FirebaseAuth auth = FirebaseAuth.instance;<br>  final FirebaseService _service = FirebaseService();<br>  late Future&lt;List&lt;UserModel&gt;&gt; _usersFuture;<br><br>  @override<br>  void initState() {<br>    super.initState();<br>    _usersFuture = _service.getAllUsersExceptCurrent();<br><br>    ZegoUIKitPrebuiltCallInvitationService().init(<br>      appID: AppConfig.appid,<br>      appSign: AppConfig.appsign,<br>      userID: widget.firebaseUser.uid,<br>      userName: widget.firebaseUser.displayName ?? widget.firebaseUser.email!,<br>      plugins: [ZegoUIKitSignalingPlugin()],<br>    );<br>  }<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(<br>        title: Text(&quot;Contacts&quot;),<br>        actions: [<br>          ElevatedButton(<br>            onPressed: () {<br>              _service.signOut();<br>            },<br>            child: Text(&quot;Logout&quot;),<br>          ),<br>        ],<br>      ),<br>      body: FutureBuilder(<br>        future: _usersFuture,<br>        builder: (context, snapshot) {<br>          if (snapshot.connectionState == ConnectionState.waiting) {<br>            return Center(child: CircularProgressIndicator());<br>          } else if (snapshot.hasError) {<br>            return Center(child: Text(&quot;Error showing users&quot;));<br>          } else if (!snapshot.hasData || snapshot.data!.isEmpty) {<br>            return Center(child: Text(&#39;No users found&#39;));<br>          }<br>          final users = snapshot.data!;<br>          return ListView.builder(<br>            itemCount: users.length,<br>            itemBuilder: (context, index) {<br>              final user = users[index];<br>              return Padding(<br>                padding: const EdgeInsets.symmetric(<br>                  vertical: 4,<br>                  horizontal: 12,<br>                ),<br>                child: UserCallWidget(user: user),<br>              );<br>            },<br>          );<br>        },<br>      ),<br>    );<br>  }<br>}</pre><p>The UserCallWidget(user: user) is an important widget to our implementation, as it contains two buttons, which are two ZegoSendCallInvitationButton, these buttons have a parameter isVideoCall, which has a ‘bool’ type, when it’s true, video call is initiated, when it is false, voice call is initiated.</p><pre>ZegoSendCallInvitationButton(<br>                margin: EdgeInsets.all(6),<br>                timeoutSeconds: 20,<br>                buttonSize: Size(38, 38),<br>                icon: ButtonIcon(icon: Icon(Icons.phone, color: Colors.blue)),<br>                iconSize: Size(38, 38),<br>                isVideoCall: false,<br>                resourceID: &quot;zego&quot;, <br>                invitees: [ZegoUIKitUser(id: user.uid, name: user.name)],<br>                onWillPressed: () async {<br>                  if (ZegoUIKitPrebuiltCallInvitationService().isInCalling) {<br>                    ScaffoldMessenger.of(context).showSnackBar(<br>                      const SnackBar(content: Text(&quot;You&#39;re already in a call&quot;)),<br>                    );<br>                    return false;<br>                  }<br>                  return true;<br>                },<br>              ),</pre><p>The onWillPressed parameter helps to determine when the user is in a call and knows how to manage incoming calls.</p><pre>onWillPressed: () async {<br>                  if (ZegoUIKitPrebuiltCallInvitationService().isInCalling) {<br>                    ScaffoldMessenger.of(context).showSnackBar(<br>                      const SnackBar(content: Text(&quot;You&#39;re already in a call&quot;)),<br>                    );<br>                    return false;<br>                  }<br>                  return true;<br>                },</pre><p>Below is the full user call widget code.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:zego/model/usermodel.dart&#39;;<br>import &#39;package:zego_uikit_prebuilt_call/zego_uikit_prebuilt_call.dart&#39;;<br><br>class UserCallWidget extends StatelessWidget {<br>  final UserModel user;<br><br>  const UserCallWidget({<br>    super.key,<br>    required this.user,<br>  });<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Container(<br>      decoration: BoxDecoration(color: Colors.white60),<br>      child: ListTile(<br>        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),<br>        leading: CircleAvatar(<br>          radius: 25,<br>          child: Center(child: Text(user.name.substring(0, 1).toUpperCase())),<br>        ),<br>        title: Text(user.username),<br>        trailing: Container(<br>          width: 88,<br>          child: Row(<br>            children: [<br>              ZegoSendCallInvitationButton(<br>                margin: EdgeInsets.all(6),<br>                timeoutSeconds: 20,<br>                buttonSize: Size(38, 38),<br>                icon: ButtonIcon(icon: Icon(Icons.phone, color: Colors.blue)),<br>                iconSize: Size(38, 38),<br>                isVideoCall: false,<br>                resourceID: &quot;zego&quot;, <br>                invitees: [ZegoUIKitUser(id: user.uid, name: user.name)],<br>                onWillPressed: () async {<br>                  if (ZegoUIKitPrebuiltCallInvitationService().isInCalling) {<br>                    ScaffoldMessenger.of(context).showSnackBar(<br>                      const SnackBar(content: Text(&quot;You&#39;re already in a call&quot;)),<br>                    );<br>                    return false;<br>                  }<br>                  return true;<br>                },<br>              ),<br>              ZegoSendCallInvitationButton(<br>                timeoutSeconds: 20,<br>                buttonSize: Size(38, 38),<br>                icon: ButtonIcon(icon: Icon(Icons.videocam, color: Colors.blue)),<br>                iconSize: Size(38, 38),<br>                isVideoCall: true,<br>                resourceID: &quot;zego&quot;, <br>                invitees: [ZegoUIKitUser(id: user.uid, name: user.name)],<br>                onWillPressed: () async {<br>                  if (ZegoUIKitPrebuiltCallInvitationService().isInCalling) {<br>                    ScaffoldMessenger.of(context).showSnackBar(<br>                      const SnackBar(content: Text(&quot;You&#39;re already in a call&quot;)),<br>                    );<br>                    return false;<br>                  }<br>                  return true;<br>                },<br>              ),<br>            ],<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>With all these implemented, our app is almost ready to make video and voice call. Before we run the app we have to setup the app for both Android and iOS.</p><p><strong>Configure your project for Android</strong></p><p>In the top level of your project folder, head to the android folder, then open the app build.gradle.kts file, and add the following.</p><ol><li>Add these to the dependencies android/app/build.gradle.kts</li></ol><pre>dependencies {<br>    // Introduce Firebase BoM (Bill of Materials)<br>    implementation(platform(&quot;com.google.firebase:firebase-bom:31.0.2&quot;))<br><br>    // Firebase Analytics and Messaging (FCM)<br>    implementation(&quot;com.google.firebase:firebase-analytics&quot;)<br>    implementation(&quot;com.google.firebase:firebase-analytics&quot;)<br>    implementation(&quot;com.google.firebase:firebase-messaging&quot;)<br><br>    // ZPNs package for Google FCM push<br>    implementation(&quot;im.zego:zpns-fcm:2.8.0&quot;)<br>}</pre><p>2. change the ‘minSdk’</p><pre>minSdk = 23 </pre><p>3. In the releases section, add the following for the proguard file which we will add later.</p><pre> release {<br>            proguardFiles(getDefaultProguardFile(&quot;proguard-android.txt&quot;),file(&quot;proguard-rules.pro&quot;))<br>        }</pre><p>4. Update your dependencies section to have the needed dependencies,.</p><pre>dependencies {<br>    // Introduce Firebase BoM (Bill of Materials)<br>    implementation(platform(&quot;com.google.firebase:firebase-bom:31.0.2&quot;))<br><br>    // Firebase Messaging (FCM)<br>    implementation(&quot;com.google.firebase:firebase-messaging&quot;)<br><br>    // ZPNs package for Google FCM push<br>    implementation(&quot;im.zego:zpns-fcm:2.8.0&quot;)<br>}</pre><p>In the android folder, head into the settings.gradle.kts and implement these changes in the plugins section.</p><pre>plugins {<br>    id(&quot;dev.flutter.flutter-plugin-loader&quot;) version &quot;1.0.0&quot;<br>    id(&quot;com.android.application&quot;) version &quot;8.7.0&quot; apply false<br>    // START: FlutterFire Configuration<br>    id(&quot;com.google.gms.google-services&quot;) version(&quot;4.3.15&quot;) apply false<br>    // END: FlutterFire Configuration<br>    id(&quot;org.jetbrains.kotlin.android&quot;) version &quot;1.8.22&quot; apply false<br>}</pre><p>Head into the gradle/wrapper folder and make the distributionUrl to have gradle 8 &gt; in my case the below is what I have.</p><pre>distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip</pre><p>Modify permissions in the Android manifest file by going to /android/app/src/main/AndroidManifest.xml and putting the below permissions just after the manifest tag.</p><pre>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.ACCESS_WIFI_STATE&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.BLUETOOTH&quot; /&gt;<br><br>&lt;uses-permission android:name=&quot;android.permission.RECORD_AUDIO&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.MODIFY_AUDIO_SETTINGS&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.CAMERA&quot; /&gt;<br><br>&lt;uses-permission android:name=&quot;android.permission.WAKE_LOCK&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.VIBRATE&quot;/&gt;<br><br>&lt;uses-permission android:name=&quot;android.permission.ACCESS_NOTIFICATION_POLICY&quot;/&gt;<br>&lt;uses-permission android:name=&quot;android.permission.POST_NOTIFICATIONS&quot;/&gt;<br>&lt;!--for bring app to foreground from background in Android 10 --&gt;<br>&lt;uses-permission android:name=&quot;android.permission.SYSTEM_ALERT_WINDOW&quot; /&gt;</pre><p>To prevent code obfuscation, we create ‘proguard-rules.pro’ in the android/app/ folder.</p><pre>-keep class **.zego.** { *; }</pre><p>Configure your project for iOS</p><ol><li>Open the ios folder, head to the podfile and paste the following to the ‘post_install do |installer|’ section.</li></ol><pre># Start of the permission_handler configuration<br>target.build_configurations.each do |config|<br>  config.build_settings[&#39;GCC_PREPROCESSOR_DEFINITIONS&#39;] ||= [<br>    &#39;$(inherited)&#39;,<br>    &#39;PERMISSION_CAMERA=1&#39;,<br>    &#39;PERMISSION_MICROPHONE=1&#39;,<br>  ]<br>end<br># End of the permission_handler configuration</pre><p>2. In the ios folder, open the Runner folder and update the ‘dict’ section of the info.plist file, ‘/ios/Runner/Info.plist’.</p><pre>&lt;key&gt;NSCameraUsageDescription&lt;/key&gt;<br>&lt;string&gt;We require camera access to connect&lt;/string&gt;<br>&lt;key&gt;NSMicrophoneUsageDescription&lt;/key&gt;<br>&lt;string&gt;We require microphone access to connect&lt;/string&gt;</pre><p>After you have followed these steps, we are now ready to test our vioce and video chat app. Go to your terminal and run, flutter run to test the app.</p><pre>flutter run</pre><p>Zegocloud has helped us build features which would have taken a long time and a lot of resources to build, within fastest possible time.</p><p><strong>Final Output</strong></p><p>Below is the final output of our app, as a user can now make a voice or video call to another user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uu7u9pC5GQaF8sLRyEJu0g.jpeg" /></figure><p><strong>Conclusion</strong></p><p>This guide has shown the implementation of Zegocloud voice and video call UIKit, which has made it easy to implement calling functionalities in our app with few lines of code, and also providing an easily customizable UI. If you prefer to follow the video tutorial, you can <a href="https://youtu.be/vjI3yn7EWV8">view it here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac8a17530c32" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Common Mobile Development Platforms and their Software Architecture Patterns.]]></title>
            <link>https://medium.com/@oriohac/common-mobile-development-platforms-and-their-software-architecture-patterns-369e0f6e0517?source=rss-bb7a8c9b98b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/369e0f6e0517</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[architecture-design]]></category>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[mobile-development]]></category>
            <dc:creator><![CDATA[Chikezirim Orioha]]></dc:creator>
            <pubDate>Sat, 29 Jun 2024 22:32:38 GMT</pubDate>
            <atom:updated>2024-06-29T22:32:38.617Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Mobile development becomes more easy when done the right way, with the right tools and implementing each process with the required or best fit software architecture. There are many mobile development platforms which are used for application development, some which are for native application development and others for cross-platform application development. The two major native development platforms are the Android Studio(the official Integrated Development Environment for Android development) which supports, Kotlin, Java, C++ and Xcode(the official Integrated Development Environment for iOS development) which supports Objective-C and Swift. Some of the major Cross-Platform platforms are, Flutter, React Native, Xamarin and Ionic. There are also Game development platforms No-code development platforms like Unity and Unreal Engine, Flutterflow and Appgyver.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OOGRA5nbmNqWd6sxgVXl8g.png" /><figcaption>Common Mobile Development Platforms and their Software Architecture Patterns.</figcaption></figure><h4>Table of Contents</h4><ul><li>Introduction</li><li>Native Development Platforms</li><li>Android Studio</li><li>Software Architecture Patterns</li><li>Xcode</li><li>Software Architecture Patterns</li><li>Cross-platform Development Platforms</li><li>Flutter</li><li>Software Architecture Patterns</li><li>Pros and Cons of Some of the Architectures</li><li>Personal Experience and <a href="https://hng.tech/internship">HNG Internship</a> Journey</li><li>Conclusion</li></ul><h3>Native Development Platforms</h3><p>Two of the major mobile application Operating Systems are the android OS and the Apple iOS, and the two Native development platforms for these two Operating Systems are the Android studio and the Xcode.</p><h3>Android Studio</h3><p>The Android Studio is the official IDE for Android application development, which supports the use of Kotlin, Java, and C++(can also extend to accept the use of dart, Kotlin Multiplatform Mobile KMM and Jetpack Compose) to develop mobile applications.</p><h3>Software Architecture Patterns</h3><p>Some of the Software Architecture Patterns used in Android development are the MVC (Model-View-Controller), MVP (Model-View-Presenter)</p><p><strong>MVC (Model-View-Controller)</strong>:</p><ul><li><strong>Model</strong>: This Manages the data and also manages the logic of the application.</li><li><strong>View</strong>: Represents the User Interface components which displays the data that is visible to the user.</li><li><strong>Controller</strong>: Acts as a connection between the Model and View.</li></ul><p><strong>MVP (Model-View-Presenter)</strong>:</p><ul><li><strong>Model</strong>: The Model in this case manages the data.</li><li><strong>View</strong>: The view is responsible for displaying data and handling user inputs.</li><li><strong>Presenter</strong>: Retrieves data from the Model and updates the View.</li></ul><p><strong>Unidirectional Data Flow (UDF)</strong>:</p><ul><li>This is mostly used in Jetpack Compose, where data follows a single direction or flows in a single direction from state to User Interface.</li></ul><h3>Xcode</h3><p>Xcode is the official Integrated Development Environment for iOS application development, which supports Objective-C and Swift. It includes and not limited to a code editor, a graphical interface designer, a debugger, and an iOS simulator.</p><h3>Software Architecture Patterns</h3><p>Just like in Android, iOS has the same software architecture patterns which is implemented in application development. Some of these Architecture are: MVC ( Model View Controller), MVP ( Model View Presenter) and MVVM (Model View ViewModel).</p><p><strong>MVVM (Model View ViewModel):</strong></p><p>In this pattern as was not discussed in the Android Development platform, has the Model, View and ViewModel, with their duties listed below.</p><ul><li><strong>Model</strong>: Provides data representation and business logic.</li><li><strong>View</strong>: Makes the data visible and interacts with the end user.</li><li><strong>ViewModel</strong>: Manages the data which will be presented to the View, and handles UI-related data.</li></ul><h3>Cross-platform Development Platforms</h3><p>Some of the major Cross-Platform platforms are, Flutter, React Native, Xamarin and Ionic. These platforms allows code once and run in different platforms concept.</p><h3>Flutter</h3><p>Flutter is a cross-platform application development platform created by Google, which allows to write in a single code base which uses the Dart language and it is compiled to platforms like, Android, iOS, Web and Desktop.</p><h3>Software Architecture Patterns</h3><h3>BLoC (Business Logic Component) Pattern</h3><p>Business Logic Component known as BLoC is a vastly used architecture pattern in Flutter which focuses on keeping User Interface and Business Logic separately. It involves the use of streams and sinks to handle data flow. User Interface components known as ‘Widgets’ in Flutter interact with the BLoC layer to get data and send events. The BLoC layer holds the logic, processes events, and updates the app state. This pattern enhances reusability, testability, and makes the application more reactive.</p><h3>Provider Pattern</h3><p>Another widely used pattern in Flutter is the Provider Pattern. It is based on the concept of dependency injection and creates an easy way to manage state. The Provider class acts as the data source, and other Widgets can have access and update this data. By using the Provider pattern, developers can easily share and manage state across multiple screens, improving code modularity and reducing boilerplate code.</p><h3>Pros and Cons of Some of the Architectures</h3><h3>Pros of MVC architecture</h3><ul><li>Development of the application becomes fast.</li><li>Easy for multiple developers to collaborate and work together.</li><li>Easier to Update the application.</li><li>Easier to Debug as we have multiple levels properly written in the application.</li></ul><h3>Cons of MVC architecture</h3><ul><li>It may become unscalable at some point.</li><li>It is hard to understand the MVC architecture.</li><li>Must have strict rules on methods.</li></ul><h3>Pros of MVVM architecture</h3><ul><li>Easier to develop</li><li>Easy to Test</li><li>Easy to Maintain</li></ul><h3>Cons of MVVM architecture</h3><ul><li>Difficult to debug</li><li>Complex</li></ul><h3>Pros of Business Logic Component (BLoC)</h3><ul><li>Easy to separate UI from logic</li><li>Easy to test code</li><li>Easy to reuse code</li><li>Good performance</li></ul><h3>Cons of Business Logic Component (BLoC)</h3><ul><li>More Boilerplate</li></ul><h3>Personal Experience and <a href="https://hng.tech/internship">HNG Internship</a> Journey</h3><p>As a lover of technology and who loves to create, I took on a challenge to learn mobile app development, starting off from Native android development, using Kotlin and XML, then progressed to cross-platform development using Flutter, but being self-taught means I may have missed some of the key areas which I needed better understanding mobile development, for this reason I didn’t think twice to grab the opportunity to join the <a href="https://hng.tech/internship">HNG11 internship</a>, which is a fast paced internship that will help me weigh my abilities in mobile development, and know whether I am ready for the global market.</p><p>This Internship is a timely one, as focus may be lost when you don’t have a mentor guiding you or a deadline to beat.</p><h3>Conclusion</h3><p>Mobile development becomes straight forward and easier when done with the right tools, knowledge and understanding of the right architecture of each mobile development platforms, with <a href="https://hng.tech/internship">HNG internship</a>, these requirements to be at the top of my mobile development journey will be met, and set me right to be ahead of the curve.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=369e0f6e0517" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Build Mobile Apps With Django and Flutter.]]></title>
            <link>https://medium.com/django-unleashed/easy-steps-to-connect-django-and-flutter-mobile-apps-b80de633191a?source=rss-bb7a8c9b98b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/b80de633191a</guid>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <dc:creator><![CDATA[Chikezirim Orioha]]></dc:creator>
            <pubDate>Wed, 20 Mar 2024 06:53:30 GMT</pubDate>
            <atom:updated>2026-04-15T01:57:22.022Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Some mobile developers who develop with Flutter opt to make use of some of the BaaS (backend as a service) that are out there because they may find it difficult to build on different platforms and integrate the data of each platform in a seamless and efficient way. Using some of these BaaS may make a developer lose control over some functionalities of their app or lose flexibility in how they want their data to be structured and stored between different platforms.</p><p>Django, which is a Python web framework that is used to develop flexible, secured, and dynamic web applications that utilise an MVT (Model, Views, and Template) approach, can be used as our backend for mobile applications, as opposed to using some BaaS like Firebase, Netlify, and AWS Amplify, so that our data can be easily stored and shared between different platforms. Also, the cost of hosting your apps can be reduced when you can easily host your Django apps with shared hosting platforms like Namecheap.</p><p>We will look at steps to connect Django, which will be our server, and Flutter, the mobile app frontend. To follow this article, you need Python set up on your computer, as Django, which is a <a href="http://python.org/">Python</a> framework, needs it to run, and <a href="https://www.notion.so/Easy-Steps-to-Connect-Django-and-Flutter-Mobile-Apps-3aeaf9737922413d86c6468c42e92946?pvs=21">Flutter</a> also needs to be set up on your device. I am using an Ubuntu 22.04.4 LTS-powered system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uM3Kdm20PmpNtIL6JQxfXw.png" /></figure><h3>Getting Started With Django</h3><p>We will start off by creating a Django project, and before we create the Django project, we have to create a virtual environment. The virtual environment helps to isolate our dependencies and packages from other projects and from system-wide dependencies and packages. There are different virtual environments out there, but we will use pipenv in this illustration. Go to your terminal and enter the command below.</p><pre>pip install virtualenv pipenv</pre><p>Furthermore, we go ahead and create the directory where our project will be situated; in this directory, the Django and Flutter projects will be located. To achieve this, enter the below command in your terminal, which should be in your project’s working directory.</p><pre>mkdir PyFlPro</pre><p>In this case, a folder named PyFlPro will be created, but still, in the terminal, change the directory to this folder by entering cd PyFlPro in the new directory and creating another directory where the Django project will be.</p><pre>mkdir dev_Django</pre><p>Move into the new folder dev_Django with the command cd dev_Django and activate the virtual environment using the below command.</p><pre>virtualenv .env</pre><p>This creates a new hidden folder called .env, which contains the virtual environment files. Finally, activate the virtual environment with the command below.</p><pre>source dev_Django/.env/bin/activate</pre><p>The next step is to install Django in our newly created virtual environment, and this can be achieved with the following command:</p><pre>pip install django</pre><p>To get our project up, we then have to start a project with the below command.</p><pre>django-admin startproject djangoFl</pre><p>Also, an app will be created in the project folder, so change the directory to the created project by cd djangoFl, and then create the app with the below command.</p><pre>python3 manage.py startapp apiApp</pre><p>After creating the app, ensure you update the INSTALLED_APPS section of your settings.py file, including the name of the app as a string. To test if our setup was successful, we will then test the Django project by running the server with the command below.</p><pre>python3 manage.py runserver</pre><p>If everything worked fine, you can see the Django welcome screen when you navigate to 127.0.0.1:8000 in your browser.</p><h3>Creating API</h3><p>We need to create a pathway that will help us communicate between these two platforms, and to do that, Django has provided an out-of-the-box package that helps in creating and testing your APIs, which is the Django REST Framework. We will install this package and include it in the INSTALLED_APPS section of our project’s settings.py file. Run the following command to install the package:.</p><pre>pip install djangorestframework</pre><p>After that, we update the INSTALLED_APPS section of the settings file with the below code.</p><pre># Application definition<br>INSTALLED_APPS = [<br>    &#39;django.contrib.admin&#39;,<br>    &#39;django.contrib.auth&#39;,<br>    &#39;django.contrib.contenttypes&#39;,<br>    &#39;django.contrib.sessions&#39;,<br>    &#39;django.contrib.messages&#39;,<br>    &#39;django.contrib.staticfiles&#39;,<br>    &#39;apiApp&#39;,<br>    &#39;rest_framework&#39;,<br>]</pre><p>Moving ahead, we create a urls.py file in our app folder and update the url.py file in the project folder with the code below.</p><pre>urlpatterns = [<br>    ...,<br>    path(&#39;&#39;,include(&#39;apiApp.urls&#39;)),<br>    ...,<br>]</pre><h3>Models</h3><p>We then go ahead to follow the MVT architecture to implement the Django project. In this project, we will be able to create a blog post, update it, and delete it when we navigate to the corresponding urls. First, let’s set up our models. Open your models.py file and key in the code below.</p><pre>from django.db import models<br># Create your models here.<br>class Blog(models.Model):<br>    topic = models.CharField(max_length=200)<br>    body = models.TextField()<br>#Your Model Identity<br>    class Meta:<br>        verbose_name = (&quot;Blog&quot;)<br>        verbose_name_plural = (&quot;Blogs&quot;)<br>    def __str__(self):<br>        return self.topic</pre><h3>View</h3><p>Now that we are done with our model, which has a topic, a body field, and an auto-id field, which serves as a primary key, we proceed to create the views, where the logic of the project is written. In the views.py file of the app we created, we will create a BlogListview() class with the ListView parameter passed into it. This class lists or ‘gets’ the data from the model, and it will be displayed on a template known as list.html, as seen below.</p><pre>class BlogListview(ListView):<br>    model = Blog<br>    fields = [<br>        &#39;topic&#39;,<br>        &#39;body&#39;<br>    ]<br>    template_name = &#39;list.html&#39;</pre><p>The next view class is the BlogCreateview(), which is used to create new objects in the model, and the CreateView is passed into it.</p><pre>class BlogCreateview(CreateView):<br>    model = Blog<br>    fields = [&#39;topic&#39;,&#39;body&#39;]<br>    template_name = &#39;newpost.html&#39;<br>    success_url = &#39;/&#39;</pre><p>Furthermore, we move to the next view element, which is the BlogDeleteview(), which deletes a particular object in the model given its id, and this class has the DeleteView passed into it.</p><pre>class BlogDeleteview(DeleteView):<br>    model = Blog<br>    template_name = &#39;delete.html&#39;<br>    success_url = &#39;/&#39;</pre><p>The next is the UpdateView, which is passed into the BlogUpdateview() class. It allows the entering of new information into already-created fields. Below is the update view code.</p><pre>class BlogUpdateview(UpdateView):<br>    model = Blog<br>    fields = &#39;__all__&#39;<br>    template_name = &#39;newpost.html&#39;<br>    success_url = &#39;/&#39;</pre><p>These view classes have a success url; this is the page that the user will be taken to after a successful delete, create, or update action has been done.</p><p>The last class in the views.py class is the BlogViewset() class, which viewsets.ModelViewSet is passed into it. This is a simple class-base view that lists or creates objects; in this case, it lists all objects from our Blog model and can create serializable objects into the model with the help of a serializer from the Django REST framework.</p><pre>class BlogViewset(viewsets.ModelViewSet):<br>    queryset = Blog.objects.all()<br>    serializer_class = BlogSerializer</pre><p>We have a [views.py](&lt;http://views.py&gt;) with the below code.</p><pre>from django.views.generic import ListView<br>from django.views.generic.edit import CreateView, DeleteView, UpdateView<br>from rest_framework import viewsets<br>from .serializers import BlogSerializer<br>from .models import Blog<br># Create your views here.<br>class BlogListview(ListView):<br>    model = Blog<br>    fields = [<br>        &#39;topic&#39;,<br>        &#39;body&#39;<br>    ]<br>    template_name = &#39;list.html&#39;<br>class BlogCreateview(CreateView):<br>    model = Blog<br>    fields = [&#39;topic&#39;,&#39;body&#39;]<br>    template_name = &#39;newpost.html&#39;<br>    success_url = &#39;/&#39;<br>class BlogDeleteview(DeleteView):<br>    model = Blog<br>    template_name = &#39;delete.html&#39;<br>    success_url = &#39;/&#39;<br>class BlogUpdateview(UpdateView):<br>    model = Blog<br>    fields = &#39;__all__&#39;<br>    template_name = &#39;newpost.html&#39;<br>    success_url = &#39;/&#39;<br>class BlogViewset(viewsets.ModelViewSet):<br>    queryset = Blog.objects.all()<br>    serializer_class = BlogSerializer</pre><h3>Serializer</h3><p>The serializer class has to be created so that we can convert complex datatypes into Python datatypes, which can be easily rendered into JSON or XML. In your app folder, create a file and name it serializer.py. In the file, import the model and serializers from rest_framework, then create your BlogSerializer() class, and in the meta class, assign your model, in our case, Blog, to the model and all fields of the model to the fields parameter.</p><pre>from rest_framework import serializers<br>from .models import Blog<br>class BlogSerializer(serializers.ModelSerializer):<br>    class Meta:<br>        model = Blog<br>        fields = &#39;__all__&#39;</pre><h3>Templates</h3><p>We create corresponding templates for the template names that were written in the view classes.</p><p>First, we create the list.html template, which contains the below code.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;Document&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;h1&gt;My post&lt;/h1&gt;<br>    <br>    {% for object in object_list%}<br>     {{ object.topic}}<br>     {{ object.body}} <br>    <br>    &lt;hr/&gt;<br>{%empty%}<br>    &lt;li&gt; No object yet &lt;/li&gt;<br>     {% endfor %} <br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>The above template lists the objects of our model and divides the screen with a horizontal line for each data point. When there is no data in the model yet, a text is displayed on the screen, which reads “No object yet.”</p><p>Next is the new post. Here we create a form and use Django’s {{form.as__p}} to render the form, and a submit button to submit the form.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;Document&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;h3&gt;Make post&lt;/h3&gt;<br>    &lt;form  method=&quot;post&quot;&gt;<br>        {% csrf_token %}<br>        {{ form.as_p }}<br>        &lt;input type=&quot;submit&quot; value=&quot;post&quot; &gt;<br>    &lt;/form&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>The last template is the delete template, which asks you if you want to delete a post. On confirmation, the post is deleted,as seen below.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;Document&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;h4&gt;Delete post&lt;/h4&gt;<br>    &lt;form  method=&quot;post&quot;&gt;<br>        {% csrf_token %}<br>        &lt;p&gt;Do you want to delete {{object}}?&lt;/p&gt;<br>        &lt;input type=&quot;submit&quot; value=&quot;Confirm&quot;&gt;<br>    &lt;/form&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><h3>URL</h3><p>We update the urls.py file we created in the app folder of the Django project, as seen below.</p><pre>from django.urls import  path<br>from .views import BlogListview, BlogCreateview, BlogDeleteview, BlogUpdateview, BlogViewset<br>from rest_framework.routers import DefaultRouter<br>router = DefaultRouter()<br>router.register(&#39;rest&#39;,BlogViewset, basename=&#39;viewset&#39;)<br>urlpatterns = [<br>    path(&#39;&#39;,BlogListview.as_view(),name=&#39;List&#39;),<br>    path(&#39;new/&#39;,BlogCreateview.as_view(),name=&#39;newpost&#39;),<br>    path(&#39;delete/&lt;pk&gt;/&#39;,BlogDeleteview.as_view(),name=&#39;delete&#39;),<br>    path(&#39;update/&lt;pk&gt;/&#39;, BlogUpdateview.as_view(), name= &#39;update&#39;),<br>    <br>] + router.urls</pre><p>When we navigate to the /rest url, the REST framework viewset is shown, where the data in the model is listed, and you can also create objects and update data from there.</p><p>The delete and update paths need a &lt;pk&gt;/, which is a primary key, and this key is our id field, so that when you update or delete, it will be to a particular data.</p><p>After that, run the below command to create your database.</p><pre>python3 manage.py makemigrations</pre><p>Then migrate and run the project.</p><pre>python3 manage.py migrate</pre><p>Run the project as you did in the beginning.</p><pre>python3 manage.py runserver</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RDrBrPlTah6lT1Q6iBbNtg.png" /></figure><p>Now you can create, update, and delete data to and from your model.</p><h3>Flutter</h3><p>Now that we have created all that we need for the backend with Django, we proceed to get this working in our mobile application that we will create on Flutter. Flutter helps us build appealing cross-platform apps, ranging from Android, iOS, Windows, and Linux desktop apps to web apps. This gives you the ease to build on one code base and deploy on several platforms.</p><h3>Getting Started</h3><p>We have to create our project in the PyFlPro directory we created, so move into the directory and key in the below command to create your Flutter project.</p><pre>flutter create djangofl</pre><p>When this is done, head into the terminal of your preferred IDE and get the http package, which is needed to make API calls to the Django server.</p><pre>flutter pub add http</pre><p>This will include the latest http package under the dependencies section of your pubspec.ymal file.</p><p>Move into your lib folder and open the main.dart file. Clear the already existing codes in it so we can create what we want.</p><h3>Get Post From Your Django App</h3><p>Given that we have set up our Flutter project, we go ahead and get the data that is stored in our Django Blog model, which has topic, body, and ID fields.</p><p>Before we proceed, let us create a model class called Model, which will help convert the JSON data gotten from our server to dart-readable datatypes, as seen below.</p><pre>class Model {<br>  late String topic;<br>  late String body;<br>  late int id;<br>  Model({required this.topic, required this.body, required this.id});<br>  factory Model.fromJson(dynamic json) {<br>    return Model(<br>      id: json[&#39;id&#39;] as int,<br>      topic: json[&#39;topic&#39;] as String,<br>      body: json[&#39;body&#39;] as String,<br>    );<br>  }<br>}</pre><p>Next, we create an asynchronous function that will utilise the http package with the get() method to retrieve data from the server. If an error occurs, then an exception will be thrown.</p><pre>Future&lt;List&lt;Model&gt;&gt; getBlog() async {<br>    final response = await http.get(Uri.parse(&#39;&lt;http://127.0.0.1:8000/rest&gt;&#39;));<br>    if (response.statusCode == 200) {<br>      List&lt;dynamic&gt; apidata = jsonDecode(response.body);<br>      List&lt;Model&gt; modeldata = apidata.map((json) =&gt; Model.fromJson(json)).toList();<br>      return modeldata;<br>    } else {<br>      throw Exception(&quot;Fix: Something went wrong!!&quot;);<br>    }<br>  }</pre><p>Moving ahead, we create the user interface with the app depending on the Material App, then render a Center() widget in a Scaffold() widget so that all the data we have on the screen will be centralized, and then we pass the FutureBuilder() widget in the center widget. This widget builds itself with the latest snapshot interaction with the future. The Future helps to implement the asynchronous computation, which expects data from an external computation or from a database, unlike synchronous computation, which returns a value or exception instantly.</p><pre>Widget build(BuildContext context) {<br>    return MaterialApp(<br>      //Remove debug banner on top of your app<br>      debugShowCheckedModeBanner: false,<br>      home: Scaffold(<br>        body: Center(<br>          //FutureBuilder builds itself with the latest snapshot of future<br>          child: FutureBuilder&lt;List&lt;Model&gt;&gt;(<br>            future: blog,<br>            builder: (context, snapshot) {<br>            },<br>          ),<br>        ),<br>      ),<br>    );<br>  }</pre><p>The builder parameter in the FutureBuilder should not return null. Then we test the connection state of the snapshot, that is, when the snapshot is trying to retrieve data, a CircularProgressIndicator is displayed.</p><pre>if (snapshot.connectionState == ConnectionState.waiting) {<br>        //Display Progress Indicator as the data loads<br>         return const CircularProgressIndicator();<br>     }</pre><p>Then we test if the snapshot has data in a ListView.builder(), which is capable of displaying infinite number of data in a horizontal scrollable display, is returned, which has two parameters, one of the parameters being itemCount, which tells the ListView the number of data that is expected, and a non-null itemBuilder. Then we return a Column() widget, which takes a list of children; in this case, it will have two children, which are the topic and the body.</p><pre>else if (snapshot.hasData) {<br>                return ListView.builder(<br>                  //create listview that can take an infinite number of data<br>                    itemCount: snapshot.data!.length,<br>                    itemBuilder: (context, index) {<br>                      return Column(<br>                        //Align your post topic and body text to the start of the screen<br>                        crossAxisAlignment: CrossAxisAlignment.start,<br>                        children: [<br>                          //Topic text styled to be bold<br>                          Text(snapshot.data![index].topic,style: TextStyle(fontWeight: FontWeight.bold),),<br>                          // Body text with same index or id with topic<br>                          Text(snapshot.data![index].body),<br>                          Divider(),<br>                        ],<br>                      );<br>                    });<br>                  <br>              }</pre><p>Then throw an exception if the snapshot has any errors.</p><pre>else {<br>			//snapshot exception<br>		  throw Exception(&quot;Could not fetch data&quot;);<br>		}</pre><p>The full code to get the data from our Django server will be seen below.</p><pre>import &#39;dart:convert&#39;;<br>import &#39;package:djangofl/createpost.dart&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:http/http.dart&#39; as http;<br>void main() {<br>  runApp(const MyApp());<br>}<br>class Model {<br>  late String topic;<br>  late String body;<br>  late int id;<br>  Model({required this.topic, required this.body, required this.id});<br>  factory Model.fromJson(dynamic json) {<br>    return Model(<br>      id: json[&#39;id&#39;] as int,<br>      topic: json[&#39;topic&#39;] as String,<br>      body: json[&#39;body&#39;] as String,<br>    );<br>  }<br>}<br>class MyApp extends StatefulWidget {<br>  const MyApp({super.key});<br>  @override<br>  State&lt;MyApp&gt; createState() =&gt; _MyAppState();<br>}<br>class _MyAppState extends State&lt;MyApp&gt; {<br>  Future&lt;List&lt;Model&gt;&gt; getBlog() async {<br>    final response = await http.get(Uri.parse(&#39;&lt;http://127.0.0.1:8000/rest&gt;&#39;));<br>    if (response.statusCode == 200) {<br>      List&lt;dynamic&gt; apidata = jsonDecode(response.body);<br>      List&lt;Model&gt; modeldata = apidata.map((json) =&gt; Model.fromJson(json)).toList();<br>      return modeldata;<br>    } else {<br>      throw Exception(&quot;Fix: Something went wrong!!&quot;);<br>    }<br>  }<br>  late Future&lt;List&lt;Model&gt;&gt; blog;<br>  @override<br>  void initState() {<br>    super.initState();<br>    blog = getBlog();<br>  }<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      //Remove debug banner on top of your app<br>      debugShowCheckedModeBanner: false,<br>      home: Scaffold(<br>        body: Center(<br>          //FutureBuilder builds itself with the latest snapshot of future<br>          child: FutureBuilder&lt;List&lt;Model&gt;&gt;(<br>            future: blog,<br>            builder: (context, snapshot) {<br>              if (snapshot.connectionState == ConnectionState.waiting) {<br>                //Display Progress Indicator as the data loads<br>                return const CircularProgressIndicator();<br>              } else if (snapshot.hasData) {<br>                return ListView.builder(<br>                  //create listview that can take an infinite number of data<br>                    itemCount: snapshot.data!.length,<br>                    itemBuilder: (context, index) {<br>                      return Column(<br>                        //Align your post topic and body text to the start of the screen<br>                        crossAxisAlignment: CrossAxisAlignment.start,<br>                        children: [<br>                          //Topic text styled to be bold<br>                          Text(snapshot.data![index].topic,style: TextStyle(fontWeight: FontWeight.bold),),<br>                          // Body text with same index or id with topic<br>                          Text(snapshot.data![index].body),<br>                          Divider(),<br>                        ],<br>                      );<br>                    });<br>                  <br>              }<br>               else {<br>                //snapshot exception<br>                throw Exception(&quot;Could not fetch data&quot;);<br>              }<br>            },<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>Run your Flutter project while your Django server is running.</p><pre>flutter run</pre><p>The exception may come up because you cannot navigate to <a href="http://localhost/">localhost</a> or http://127.0.0.1:8000/rest on your emulator. In that case, you have to change the IP address from 127.0.0.1 to 10.0.2.2, which is a special alias for the host loopback interface, according to <a href="https://developer.android.com/studio/run/emulator-networking">Android documentation</a>. If you are testing on a real Android device, then you can look up port forwarding, which will help you test localhost on your Android device.</p><p>When you have successfully run your Flutter app, then you will see your blog posts. To learn further, you can play around by finding a way to create new posts, edit them, and also delete them.</p><h3>Output</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vAjwcKQjpMmgbnJFPEcwKA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b80de633191a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/django-unleashed/easy-steps-to-connect-django-and-flutter-mobile-apps-b80de633191a">How to Build Mobile Apps With Django and Flutter.</a> was originally published in <a href="https://medium.com/django-unleashed">Django Unleashed</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutterwave Integration into the Flutter Mobile Application in 2024: A Practical Guide to Payment…]]></title>
            <link>https://medium.com/@oriohac/flutterwave-integration-into-the-flutter-mobile-application-in-2024-a-practical-guide-to-payment-7a96da96b185?source=rss-bb7a8c9b98b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a96da96b185</guid>
            <category><![CDATA[payment-gateway]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[flutterwave]]></category>
            <dc:creator><![CDATA[Chikezirim Orioha]]></dc:creator>
            <pubDate>Tue, 27 Feb 2024 20:26:29 GMT</pubDate>
            <atom:updated>2024-02-27T21:02:57.239Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutterwave Integration into the Flutter Mobile Application in 2024: A Practical Guide to Payment Gateway Integration</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9C_FgNtr1DGQ6M9vthFqPg.png" /></figure><h3>Introduction</h3><p>When creating an application, whether mobile, desktop, or web-based, it is always important to know the right tools that are best suited for your project, and knowing the easy ways to implement these tools gives you an edge in your development process. Payment collection has become an integral part of many applications, as users have to make in-app purchases, buy items, pay for services, make reservations, or even rent items. All these processes involve the exchange of money from the user to the developer’s or app owner’s account, and to successfully make these payments without issues, a developer has to build a payment platform that is not just reliable but secure and efficient to serve the customer’s needs. Meanwhile, building a payment platform for each of the apps you want to publish out there may be a difficult and time-consuming process. This brings to mind your ability to choose the right tools that are best suited for your project and knowing the easy ways to implement these tools, as it is best to use payment gateways that are easier to implement and make your development journey fast.</p><p>In this article, we will integrate Flutterwave, which is a payment gateway, into a Flutter application and try to make payments in the development mode.</p><h3>To successfully follow this guide, you need to have:</h3><ul><li>A computer with working <a href="https://flutter.dev/">Flutter installation</a></li><li>Knowledge of Flutter app development</li><li>A <a href="https://flutterwave.com/">Flutterwave account</a></li><li>Code editor or an IDE(Visual Studio Code or Android Studio)</li></ul><p>Your will learn many things at the end of the article which are and not limited to:</p><ul><li>Creating and running a Flutter application</li><li>Integrating and customizing Flutterwave payment gateway</li><li>Retrieving images from an API</li></ul><p>and many other practical development practices.</p><h3>Getting Started</h3><p>To get started, make sure you have set up Flutter and it is running in your system; if not, you can get the latest version of Flutter that matches your system’s requirements when you visit the <a href="https://flutter.dev/">Flutter official site</a>. Then open your preferred IDE (I am using VsCode) and key in the below command in the terminal to start a new Flutter project in your projects directory.</p><pre>flutter create adopt_dg</pre><p>We have our project adopt_dg created in our project directory. We need to set up a few things before we dive into the main code. Head into the lib folder adopt_dg/lib/main.dart and open the main.dart file. There are some example codes in it; clean them, and you will be left with the below code.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>void main() {<br>  runApp(const MyApp());<br>}<br>class MyApp extends StatelessWidget {<br>  const MyApp({super.key});<br>  // This widget is the root of your application.<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>    );<br>  }<br>}</pre><h3>Get the Images</h3><p>We need to get some images that we will use for illustration purposes in the app. These images are dog images from the <a href="https://dog.ceo/dog-api/documentation/">DogCeo</a> free API. To learn more about how to perform some of the common actions on APIs in Flutter, you can <a href="https://medium.com/@oriohac/beginner-friendly-implementation-of-the-http-methods-get-post-put-and-delete-from-apis-in-b4e93952aa29">check out this article</a>. To get these images, we have to get some packages from Flutter’s <a href="https://pub.dev/">pub.dev</a>, which is where you get your latest Flutter packages. Search and copy the latest version of the http package, then in your project’s primary directory, open your pubspec.ymal and paste the package version under the dependencies section, and finally click the arrow-down button in the top right corner of the IDE to get this package synchronized in your project, or simply type flutter pub get to synchronize this package. When you are done, your pubspec.ymal file will look like the below code.</p><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br>  cupertino_icons: ^1.0.2<br>  http: ^1.2.0</pre><p>Now import the package into your main.dart file and go ahead to create a model that will hold the data we are getting from the API. There is also a variable imgRange in the model that helps determine the number of images we wish to retrieve from the API. The implementation of the model can be seen below.</p><pre>import &#39;package:http/http.dart&#39; as http;<br>class ImageModel {<br>  final List message;<br>  var imgRange = List;<br>  ImageModel({required this.message});<br>  factory ImageModel.fromJson(dynamic json) {<br>    return ImageModel(message: json[&#39;message&#39;] as List);<br>  }<br>}</pre><p>To appreciate what we want to implement and see our changes as they happen in our app, we need to change our app from a StatelessWidget to a StatefulWidget, then in the _MyAppState we will create an asynchronous function that will fetch these images, which is seen in the code snippet below.</p><pre>Future&lt;ImageModel&gt; getImages() async {<br>    final response = await http.get(Uri.parse(&#39;https://dog.ceo/api/breed/husky/images&#39;));<br>    if (response.statusCode == 200) {<br>      return ImageModel.fromJson(jsonDecode(response.body));<br>    } else {<br>      throw Exception(&quot;Fix: Something went wrong!!&quot;);<br>    }<br>  }</pre><p>Next, create a variable of type Future&lt;ImageModel&gt; and name it whatever you wish, but it is named image in the example. Assign the getImages() function to this variable in an initState() function so that we can get these images when our app loads. The code that implements this can be seen below.</p><pre>late Future&lt;ImageModel&gt; image;<br>  <br>  @override<br>  void initState() {<br>    super.initState();<br>    image = getImages();<br>  }</pre><p>We then work on the app’s interface, which is implemented with the code below.</p><pre>debugShowCheckedModeBanner: false,<br>      home: Scaffold(<br>        body: Center(<br>          child: FutureBuilder&lt;ImageModel&gt;(<br>              future: image,<br>              builder: (context, snapshot) {<br>                if (snapshot.connectionState == ConnectionState.waiting) {<br>                  return const CircularProgressIndicator();<br>                } else if (snapshot.hasData) {<br>                  List imageRange = snapshot.data!.message.sublist(0,10);<br>                  int imageRangelen = imageRange.length;<br>                  return ListView.builder(<br>                      itemCount: imageRangelen,<br>                      itemBuilder: (context, index) {<br>                        <br>                         return Column(<br>                           children: [<br>                             Card(<br>                              margin: const EdgeInsets.all(8.0),<br>                              elevation: 4,<br>                              shape: const RoundedRectangleBorder(<br>                                  borderRadius:<br>                                      BorderRadius.all(Radius.circular(6))),<br>                              child: Padding(<br>                                padding: const EdgeInsets.all(8.0),<br>                                child: Column(<br>                                  children: [<br>                                    Image.network(<br>                                        snapshot.data!.message[index]),<br>                                    Row(<br>                                        mainAxisAlignment:<br>                                            MainAxisAlignment.spaceBetween,<br>                                        children: [<br>                                          const Text(&quot;Adopt:&quot;),<br>                                          ElevatedButton(<br>                                              style: ElevatedButton.styleFrom(<br>                                                  shape:<br>                                                      RoundedRectangleBorder(<br>                                                          borderRadius:<br>                                                              BorderRadius<br>                                                                  .circular(<br>                                                                      2))),<br>                                              onPressed: () {<br>                                               <br>                                              },<br>                                              child: const Text(&quot;Pay&quot;))<br>                                        ])<br>                                  ],<br>                                ),<br>                              ),<br>                                                         ),<br>                           ],<br>                         );<br>                      });<br>                } else {<br>                  print(&quot;Error: ${snapshot.error}&quot;);<br>                  throw Exception(&quot;Could not fetch data&quot;);<br>                }<br>              }),<br>        ),<br>      ),</pre><p>In the above code, we disabled Flutter’s debug badge with debugShowCheckedModeBanner: false, and then in our widget, we created the FutureBuilder&lt;ImageModel&gt;() widget. When the snapshot’s connection state gotten from the builder parameter of the widget is still waiting, then we return a CircularProgressIndicator(), but if the snapshot has data, we get the number of images we want by using the list variable imageRange to get a list of 10 images, which is a sublist() of the data returned from our imageModel, and then use the integer imageRangelen to pass to the itemCount parameter of the ListView,builder() widget. In the ListView,builder() is a column that contains the image and the pay button.</p><h3>Payment Implementation</h3><p>To implement the payment gateway, we have to go to <a href="https://flutterwave.com/">Flutterwave</a> and create an account so that we can get the necessary credentials needed for a successful integration. After you have created an account, make sure you are in <strong>test mode.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FtFXkNpqjbnsjq9ZInAePQ.png" /><figcaption>Flutterwave dashboard</figcaption></figure><p>Then click on ‘Settings’ and select ‘API Keys’. You will see public, secret, and encryption keys, but what we need is the public key. Copy it and keep it safe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kPPCuuY3X1vyJ7UT0pgSHg.png" /><figcaption>Flutterwave API keys</figcaption></figure><p>Then go to <a href="https://pub.dev/">pub.dev</a> and get the latest version of the Flutterwave package and update the pubspec.ymal, as seen in the code below.</p><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br>  cupertino_icons: ^1.0.2<br>  http: ^1.2.0<br>  flutterwave_standard: ^1.0.8<br>  uuid: ^4.3</pre><p>The uuid will be used on one of the parameters in the _handlePayment() function.</p><p>To make payments, create an asynchronous function _handlePayment() and pass all the required details from Flutterwave, as seen in the code below.</p><pre>_handlePayment() async {<br>    final Customer customer = Customer(<br>        name: &#39;Bob Ram&#39;,<br>        phoneNumber: &#39;+2348123456789&#39;,<br>        email: &#39;bob@example,com&#39;);<br>    final Flutterwave flutterwave = Flutterwave(<br>        context: context,<br>        publicKey: &quot;YOUR_PUBLIC_KEY&quot;,<br>        currency: &quot;NGN&quot;,<br>        txRef: const Uuid().v1(),<br>        amount: &quot;2500&quot;,<br>        redirectUrl: &#39;YOUR_REDIRECT_URL&#39;,<br>        customer: customer,<br>        paymentOptions: &quot;card&quot;,<br>        customization: Customization(title: &quot;My Payment&quot;),<br>        isTestMode: true,<br>        );<br>    final ChargeResponse response = await flutterwave.charge();<br>    if (response != null) {<br>      print(&quot;${response.toJson()}&quot;);<br>    } else {<br>      print(&quot;no response&quot;);<br>    }<br>  }</pre><p>The email is the only required function in the customer, but context, publicKey, txRef, amount, customer, paymentOptions, customization, redirectUrl, isTestMode, and currency are all required.</p><p>We then pass the _handlePayment() function into the payment button onPressed parameter. The full code can be seen below.</p><pre>import &#39;dart:convert&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:flutterwave_standard/flutterwave.dart&#39;;<br>import &#39;package:http/http.dart&#39; as http;<br>import &#39;package:uuid/uuid.dart&#39;;<br>void main() {<br>   runApp(const MaterialApp(<br>    debugShowCheckedModeBanner: false,<br>    home: MyApp()<br>    ));<br>  <br>}<br>class ImageModel {<br>  final List message;<br>  var imgRange = List;<br>  ImageModel({required this.message});<br>  factory ImageModel.fromJson(dynamic json) {<br>    return ImageModel(message: json[&#39;message&#39;] as List);<br>  }<br>}<br>class MyApp extends StatefulWidget {<br>  const MyApp({super.key});<br>  @override<br>  State&lt;MyApp&gt; createState() =&gt; _MyAppState();<br>}<br>class _MyAppState extends State&lt;MyApp&gt; {<br>  Future&lt;ImageModel&gt; getImages() async {<br>    final response =<br>        await http.get(Uri.parse(&#39;&lt;https://dog.ceo/api/breed/husky/images&gt;&#39;));<br>    if (response.statusCode == 200) {<br>      return ImageModel.fromJson(jsonDecode(response.body));<br>    } else {<br>      throw Exception(&quot;Fix: Something went wrong!!&quot;);<br>    }<br>  }<br>  late Future&lt;ImageModel&gt; image;<br>  @override<br>  void initState() {<br>    super.initState();<br>    image = getImages();<br>  }<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      debugShowCheckedModeBanner: false,<br>      home: Scaffold(<br>        body: Center(<br>          child: FutureBuilder&lt;ImageModel&gt;(<br>              future: image,<br>              builder: (context, snapshot) {<br>                if (snapshot.connectionState == ConnectionState.waiting) {<br>                  return const CircularProgressIndicator();<br>                } else if (snapshot.hasData) {<br>                  List imageRange = snapshot.data!.message.sublist(0, 10);<br>                  int imageRangelen = imageRange.length;<br>                  return ListView.builder(<br>                      itemCount: imageRangelen,<br>                      itemBuilder: (context, index) {<br>                        return Column(<br>                          children: [<br>                            Card(<br>                              margin: const EdgeInsets.all(8.0),<br>                              elevation: 4,<br>                              shape: const RoundedRectangleBorder(<br>                                  borderRadius:<br>                                      BorderRadius.all(Radius.circular(6))),<br>                              child: Padding(<br>                                padding: const EdgeInsets.all(8.0),<br>                                child: Column(<br>                                  children: [<br>                                    Image.network(<br>                                        snapshot.data!.message[index]),<br>                                    Row(<br>                                        mainAxisAlignment:<br>                                            MainAxisAlignment.spaceBetween,<br>                                        children: [<br>                                          const Text(&quot;Adopt:&quot;),<br>                                          ElevatedButton(<br>                                              style: ElevatedButton.styleFrom(<br>                                                  shape: RoundedRectangleBorder(<br>                                                      borderRadius:<br>                                                          BorderRadius.circular(<br>                                                              2))),<br>                                              onPressed: () {<br>                                                setState(() {<br>                                                  _handlePayment();<br>                                                });<br>                                              },<br>                                              child: const Text(&quot;Pay&quot;))<br>                                        ])<br>                                  ],<br>                                ),<br>                              ),<br>                            ),<br>                          ],<br>                        );<br>                      });<br>                } else {<br>                  print(&quot;Error: ${snapshot.error}&quot;);<br>                  throw Exception(&quot;Could not fetch data&quot;);<br>                }<br>              }),<br>        ),<br>      ),<br>    );<br>  }<br>  _handlePayment() async {<br>    final Customer customer = Customer(<br>        name: &#39;Bob Ram&#39;,<br>        phoneNumber: &#39;+2348123456789&#39;,<br>        email: &#39;bob@example.com&#39;);<br>    final Flutterwave flutterwave = Flutterwave(<br>      context: context,<br>      publicKey: &quot;YOUR_FLUTTERWAVE_PUBLIC_KEY&quot;,<br>      currency: &quot;NGN&quot;,<br>      txRef: const Uuid().v1(),<br>      amount: &quot;2500&quot;,<br>      redirectUrl: &#39;YOUR_REDIRECT_URL&#39;,<br>      customer: customer,<br>      paymentOptions: &quot;card&quot;,<br>      customization: Customization(title: &quot;My Payment&quot;),<br>      isTestMode: true,<br>    );<br>    final ChargeResponse response = await flutterwave.charge();<br>    if (response != null) {<br>      print(&quot;${response.toJson()}&quot;);<br>    } else {<br>      print(&quot;no response&quot;);<br>    }<br>  }<br>}</pre><p>The currency parameter can take other currencies other than the Nigerian Naira, as it can take the USD and many others, just as the paymentOptions can accept ‘Bank transfer, USSD’ and others. The customization is where you edit the branding of the payment page, you can change the title, icon, and many other things.</p><p>When the pay button is clicked, we are redirected to the Flutterwave Checkout page, where we can key in our payment details. For the purpose of this article, you can get some <a href="https://developer.flutterwave.com/docs/integration-guides/testing-helpers/#cards">card details for testing, which are provided by Flutterwave</a>.</p><h3>Output</h3><p>Below are some of the screens of the application, showing the steps taken to complete a payment process through the payment gateway we integrated in our Flutter application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*6v4BgzDykvG2_yeQStWwng.png" /><figcaption>App interface</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*z3KrKhrsEQ257AxoEkqp3A.png" /><figcaption>Flutterwave Checkout</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*dxiD1OGLZof5LkJF9k8VQA.png" /></figure><p>Now that you have learned how to implement a payment gateway into your Flutter application, which was a purely demonstrative process, you can go ahead and build apps like e-commerce applications, online shops, bookstores and many other applications that require making payments. Your development process will now be faster, and you can do many things with the platform,such as collect payments, set reoccurring payments, split payments between different parties, and many other services, when you go ahead and customize the payment gateway parameters according to the <a href="https://developer.flutterwave.com/">Flutterwave doc</a>umentation.</p><p>The full code for the project can be accessed on <a href="https://github.com/oriohac/adopt_dg">GitHub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a96da96b185" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beginner-Friendly Implementation of the HTTP Methods (Get, Post, Put, and Delete) from APIs in…]]></title>
            <link>https://medium.com/@oriohac/beginner-friendly-implementation-of-the-http-methods-get-post-put-and-delete-from-apis-in-b4e93952aa29?source=rss-bb7a8c9b98b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4e93952aa29</guid>
            <dc:creator><![CDATA[Chikezirim Orioha]]></dc:creator>
            <pubDate>Sat, 24 Feb 2024 06:01:45 GMT</pubDate>
            <atom:updated>2024-02-25T21:22:07.156Z</atom:updated>
            <content:encoded><![CDATA[<h3>Beginner-Friendly Implementation of the HTTP Methods (Get, Post, Put, and Delete) from APIs in Flutter.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*Fpp20rv1D0SNvqt43szaeg.png" /></figure><h3>Introduction</h3><p>HTTP which stands for Hyper-Text Transfer Protocol is a protocol that helps us to communicate over the internet, communication in the sense that we can send data from a source to a destination, retrieve or get data from a source(server), update an existing data and delete it when we wish to. For us to successfully carry out these tasks, we have to rely on some of the HTTP paradigms, which include but not limited to the get method, the post, put, patch, read and delete methods. API which stands for Application Programming Interface can be referred to as data source or location, where structured data are kept which can be accessed from different platforms for software development, given that you have the right credentials to access the data.</p><p>In this article we shall set our focus on the simple ways on how one can implement some of the basic HTTP methods, which includes the get, post, put and delete methods, using Flutter which is a cross-platform framework built with Dart.</p><h3>Key takeaways</h3><ul><li>Create and Run Flutter project.</li><li>Implement http in a project.</li><li>Communicate with data from an API.</li></ul><h3>Prerequisites:</h3><p>To follow up this article you need to have these:</p><ul><li>A computer with Flutter setup on it.</li><li>Basic programming knowledge.</li><li>Understand the flutter file structure.</li><li>Working internet.</li><li>Code editor or an IDE(Visual Studio Code or Android Studio)</li></ul><p>With these we are set to dive into the application of these methods.</p><h3>Table of Contents:</h3><ul><li>Introduction</li><li>Key Takeaways</li><li>Prerequisites</li><li>Getting Started</li><li>The Get Method</li><li>The Post Method</li><li>The Put Method</li><li>The Delete Method</li><li>Final Output</li><li>Conclusion</li></ul><h3>Getting Started</h3><p>To start, we have to create a new Flutter project. By following this article, it is assumed that you have Flutter set up on your computer; if you have not, you can <a href="https://flutter.dev/">follow this link </a>to get Flutter on your computer. Once you have this ready, go into your preferred IDE and open your terminal (ctrl+` opens the terminal on VSCode). Type the following in the terminal.</p><pre>flutter create http_example</pre><p>This will create a new Flutter project with the required files and folders.</p><p>Head into the lib folder and open the main.dart file. You can see a demo counter app code; clear it so we can create what we need.</p><p>In your project home directory, open the pubspec.yaml file and paste the latest version of the http package for <a href="https://pub.dev/packages?q=http">Flutter</a>, under dependencies under Flutter.</p><pre>dependencies:<br>  flutter:<br>    sdk: flutter</pre><pre>http: ^1.2.0</pre><p>In this article, I’m using the above version, but make sure to go to <a href="https://www.pub.dev/">pub.dev</a> and copy the latest version of the package. After that, click on the “Get Packages” arrow-down icon at the top right-hand corner of vscode to get the package into your project.</p><p>The package can also be gotten into our project when we use,</p><pre>flutter pub get</pre><p>in the terminal, after we have pasted the package in the pubspec.ymal file.</p><p>After that, update your lib/main.dart file with the code below, importing the http package.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:http/http.dart&#39; as http;<br>void main() {<br>  runApp(const MyApp());<br>}<br>class MyApp extends StatelessWidget {<br>  const MyApp({super.key});<br>  <br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>    );<br>  }<br>}</pre><h3>The Get Method:</h3><p>The get method retrieves resources from a source to the destination (application). This method is very important, as it helps to populate our application with data that would have been bulky to keep in our codebase. It can be used to load many forms of data, ranging from texts, images, and files.</p><p>For us to appreciate what we want to achieve, we will change the state of the application from a StatelessWidget to a StatefulWidget, whereby the state of the application can be rebuilt given some specified actions carried out in the application. Our code will now look like the below code after we have changed it to a StatefulWidget.</p><pre>void main() {<br>  runApp(const MyApp());<br>}<br>class MyApp extends StatefulWidget {<br>  const MyApp({super.key});<br>  @override<br>  State&lt;MyApp&gt; createState() =&gt; _MyAppState();<br>}<br>class _MyAppState extends State&lt;MyApp&gt; {<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      <br>    );<br>  }<br>}</pre><p>The data we will get for this article is a list of dog images from the <a href="https://dog.ceo/dog-api/documentation/">dog ceo</a> API.</p><p>We will create a class and name it Dogmodel, where we will accept a list of messages from the API, which is in JSON format. Our Dogmodel class will look like the code below.</p><pre>class Dogmodel {<br>  final List message;<br>  var dogRange = List;<br>  Dogmodel({required this.message});<br>  factory Dogmodel.fromJson(dynamic json) {<br>    return Dogmodel(message: json[&#39;message&#39;] as List);<br>  }<br>}</pre><p>The variable dogRange is used to control the number of dog images that will be retrieved, as we are looking at retrieving only a few images from the API.</p><p>In your class _MyAppState, create an asynchronous function that, when the response from the Uri has a status code of 200, will return the Dogmodel we created and decode the body of the response from json with the jsonDecode() function. The code below will get images of the dog breed beagle, but if something goes wrong, an exception will be thrown.</p><pre>import &#39;dart:convert&#39;;<br>Future&lt;Dogmodel&gt; getDog() async {<br>    final response =<br>        await http.get(Uri.parse(&#39;https://dog.ceo/api/breed/beagle/images&#39;));<br>    if (response.statusCode == 200) {<br>      return Dogmodel.fromJson(jsonDecode(response.body));<br>    } else {<br>      throw Exception(&quot;could not fetch data&quot;);<br>    }<br>  }</pre><p>We then proceed to declare a variable called ‘get’ with a Future type of the Dogmodel, and assign the ‘getDog()’ function to the ‘get’ variable in an ‘initState()’ function.</p><pre>@override<br>  void initState() {<br>    super.initState();<br>    get = getDog();<br>  }</pre><p>After that, we now build our UI and retrieve a list of 10 dog images in a card using a ‘FutureBuilder&lt;Dogmodel&gt;()’ widget and a ‘ListView.builder()’.</p><pre>@override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      home: Scaffold(<br>        body: Center(<br>          child: FutureBuilder&lt;Dogmodel&gt;(<br>              future: get,<br>              builder: (context, snapshot) {<br>                if (snapshot.connectionState == ConnectionState.waiting) {<br>                  return const CircularProgressIndicator();<br>                } else if (snapshot.hasData) {<br>                  List dogRange = snapshot.data!.message.sublist(0,10);<br>                  int dogRangelen = dogRange.length;<br>                  return ListView.builder(<br>                      itemCount: dogRangelen,<br>                      itemBuilder: (context, index) {<br>                        <br>                         return Column(<br>                           children: [<br>                             Card(<br>                              margin: const EdgeInsets.all(8.0),<br>                              elevation: 4,<br>                              shape: const RoundedRectangleBorder(<br>                                  borderRadius:<br>                                      BorderRadius.all(Radius.circular(6))),<br>                              child: Padding(<br>                                padding: const EdgeInsets.all(8.0),<br>                                child: Column(<br>                                  children: [<br>                                    Image.network(<br>                                        snapshot.data!.message[index]),<br>                                  ],<br>                                ),<br>                              ),<br>                                                         ),<br>                           ],<br>                         );<br>                      });<br>                } else {<br>                  print(&quot;Error: ${snapshot.error}&quot;);<br>                  throw Exception(&quot;Could not fetch data&quot;);<br>                }<br>              }),<br>        ),<br>      ),<br>    );<br>  }</pre><p>You can go ahead and test the app by running:</p><pre>flutter run -d yourdevice</pre><p>The ‘yourdevice’ can be any platform you want to test your application on; it may be Chrome, Linux, Windows, iPhone, Android emulator, or your attached physical Android device.</p><p>Or you can simply type:</p><pre>flutter run</pre><p>in the terminal, then choose a device from the list of devices in the terminal.</p><h3>Output</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*kbmkp-ciYEnArx8Hae3dLg.png" /><figcaption>Output of http get method from DogCeo</figcaption></figure><h3>The Post Method:</h3><p>The post method is similar to the create keyword, which is used in database management and represents the C in CRUD (Create, Read, Update, and Delete). The post method helps send resources from a user end to the server, and in turn, if this request is successful, there will be a 201 response; if not, an error or exception will be thrown. We will use a free API from <a href="https://jsonplaceholder.typicode.com/"><strong>Jsonplaceholder</strong></a> and show a success message in a snackBar if the request was successful and show an an error message if something went wrong. This will help us understand this concept better.</p><p>To start, we will create a button in the appBar, which will lead us to the page where we will implement the post, put, and delete methods with the code below.</p><pre>appBar: AppBar(<br>              actions: [<br>                Padding(<br>                  padding: const EdgeInsets.all(8.0),<br>                  child: ElevatedButton(<br>                    style: ElevatedButton.styleFrom(backgroundColor: Colors.purpleAccent,shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(6))),<br>                      onPressed: () {<br>                        Navigator.push(context, MaterialPageRoute(builder: (BuildContext context)=&gt; const OtherMethods()));<br>                      }, child: const Text(&quot;Other Methods&quot;,style: TextStyle(color: Colors.white),)),<br>                )<br>              ],),</pre><p>Then we create an asynchronous function to post data.</p><pre>Future&lt;void&gt; postData() async {<br>      var response = await http.post(<br>          Uri.parse(&#39;https://jsonplaceholder.typicode.com/posts&#39;),<br>          headers: {&quot;content-type&quot;: &quot;application/json&quot;},<br>          body: jsonEncode({<br>            &quot;userId&quot;: &#39;2&#39;,<br>            &quot;title&quot;: &#39;Introduction to API&#39;,<br>            &quot;body&quot;: &#39;This is just a demo of what you can do&#39;<br>          }));<br>      if (response.statusCode == 201) {<br>        ScaffoldMessenger.of(context).showSnackBar(const SnackBar(<br>          behavior: SnackBarBehavior.floating,<br>          backgroundColor: Color.fromARGB(255, 122, 245, 126),<br>          duration: Duration(seconds: 7),<br>          content: Text(&quot;Post Created Successfuly&quot;),<br>          shape: RoundedRectangleBorder(<br>              borderRadius: BorderRadius.all(Radius.circular(36))),<br>          showCloseIcon: true,<br>          dismissDirection: DismissDirection.horizontal,<br>          closeIconColor: Colors.white,<br>        ));<br>      } else {<br>        ScaffoldMessenger.of(context).showSnackBar(const SnackBar(<br>          behavior: SnackBarBehavior.floating,<br>          content: Row(<br>            children: [<br>              Icon(<br>                Icons.warning_amber,<br>                color: Colors.yellow,<br>              ),<br>              SizedBox(<br>                width: 18,<br>              ),<br>              Text(&quot;Something went wrong!&quot;)<br>            ],<br>          ),<br>          backgroundColor: Colors.red,<br>        ));<br>        throw Exception(&quot;Could not Post Data&quot;);<br>      }<br>    }</pre><p>This function will be passed into a setState() function in a button.</p><pre>Padding(<br>            padding: const EdgeInsets.all(12.0),<br>            child: Column(<br>              mainAxisAlignment: MainAxisAlignment.center,<br>              children: [<br>                Padding(<br>                  padding: const EdgeInsets.all(8.0),<br>                  child: SizedBox(<br>                    width: double.maxFinite,<br>                    child: ElevatedButton(<br>                        style: ElevatedButton.styleFrom(<br>                            backgroundColor: Colors.purpleAccent,<br>                            shape: RoundedRectangleBorder(<br>                                borderRadius: BorderRadius.circular(6))),<br>                        onPressed: () {<br>                          setState(() {<br>                            postData();<br>                          });<br>                        },<br>                        child: const Text(<br>                          &quot;POST&quot;,<br>                          style: TextStyle(color: Colors.white),<br>                        )),<br>                  ),<br>                ),</pre><h3>The Put Method:</h3><p>The put method is used to update data on the server, and the code to implement it is seen below. A putData() asynchronous function was created and also passed into a button, so that when clicked it will update the data under the given userId.</p><pre>Future&lt;void&gt; putData() async {<br>      var response = await http.put(<br>          Uri.parse(&#39;https://jsonplaceholder.typicode.com/posts/2&#39;),<br>          headers: {&quot;content-type&quot;: &quot;application/json&quot;},<br>          body: jsonEncode({<br>            &quot;userId&quot;: &#39;2&#39;,<br>            &quot;title&quot;: &#39;Introduction to API&#39;,<br>            &quot;body&quot;:<br>                &#39;You have learnt some of these concepts now is the time to apply them.&#39;<br>          }));<br>      if (response.statusCode == 200) {<br>        ScaffoldMessenger.of(context).showSnackBar(const SnackBar(<br>          behavior: SnackBarBehavior.floating,<br>          backgroundColor: Color.fromARGB(255, 122, 245, 126),<br>          duration: Duration(seconds: 7),<br>          content: Text(&quot;Post Updated Successfuly&quot;),<br>          shape: RoundedRectangleBorder(<br>              borderRadius: BorderRadius.all(Radius.circular(36))),<br>          showCloseIcon: true,<br>          dismissDirection: DismissDirection.horizontal,<br>          closeIconColor: Colors.white,<br>        ));<br>      } else {<br>        ScaffoldMessenger.of(context).showSnackBar(const SnackBar(<br>          behavior: SnackBarBehavior.floating,<br>          content: Row(<br>            children: [<br>              Icon(<br>                Icons.warning_amber,<br>                color: Colors.yellow,<br>              ),<br>              SizedBox(<br>                width: 18,<br>              ),<br>              Text(&quot;Something went wrong!&quot;)<br>            ],<br>          ),<br>          backgroundColor: Colors.red,<br>        ));<br>        throw Exception(&quot;Could not update Data&quot;);<br>      }<br>    }</pre><p>This function is then passed into the button below.</p><pre>Padding(<br>                  padding: const EdgeInsets.all(8.0),<br>                  child: SizedBox(<br>                    width: double.maxFinite,<br>                    child: ElevatedButton(<br>                        style: ElevatedButton.styleFrom(<br>                            backgroundColor: Colors.purpleAccent,<br>                            shape: RoundedRectangleBorder(<br>                                borderRadius: BorderRadius.circular(6))),<br>                        onPressed: () {<br>                          setState(() {<br>                            putData();<br>                          });<br>                        },<br>                        child: const Text(<br>                          &quot;PUT&quot;,<br>                          style: TextStyle(color: Colors.white),<br>                        )),<br>                  ),<br>                ),</pre><h3>The Delete Method</h3><p>The delete method, as the name goes, helps to remove resources from the server. This is achieved by creating an asynchronous function and using the http.delete() method to implement the delete. The implementation can be seen below.</p><pre>Future&lt;void&gt; deleteData() async {<br>      var response = await http.delete(Uri.parse(&#39;https://jsonplaceholder.typicode.com/posts/${3}&#39;));<br>    }</pre><p>If the asynchronous function returns a response of a 200 status code, which means the delete operation was successful, then a SnackBar() which contains the success message will be shown, which is implemented with the code below.</p><pre>if (response.statusCode == 200) {<br>        ScaffoldMessenger.of(context).showSnackBar(const SnackBar(<br>          behavior: SnackBarBehavior.floating,<br>          backgroundColor: Colors.green,<br>          duration: Duration(seconds: 7),<br>          content: Text(&quot;Post delete Success&quot;),<br>          shape: RoundedRectangleBorder(<br>              borderRadius: BorderRadius.all(Radius.circular(36))),<br>          showCloseIcon: true,<br>          dismissDirection: DismissDirection.horizontal,<br>          closeIconColor: Colors.white,<br>        ));<br>      }</pre><p>If there was an error when you wanted to carry out the delete operation, then a SnackBar() which contains the error message will be shown, and an Exception() message will be printed in the terminal, which is implemented with the code below.</p><pre>else {<br>        ScaffoldMessenger.of(context).showSnackBar(const SnackBar(<br>          behavior: SnackBarBehavior.floating,<br>          content: Row(<br>            children: [<br>              Icon(<br>                Icons.warning_amber,<br>                color: Colors.yellow,<br>              ),<br>              SizedBox(<br>                width: 18,<br>              ),<br>              Text(&quot;Something went wrong!&quot;)<br>            ],<br>          ),<br>          backgroundColor: Colors.red,<br>        ));<br>        throw Exception(&quot;Could not delete Data&quot;);<br>      }</pre><p>This deleteData() function is also passed into a button, so we can test it from our app’s interface. This is achieved with the code below.</p><pre>Padding(<br>                  padding: const EdgeInsets.all(8.0),<br>                  child: SizedBox(<br>                    width: double.maxFinite,<br>                    child: ElevatedButton(<br>                        style: ElevatedButton.styleFrom(<br>                            backgroundColor: Colors.purpleAccent,<br>                            shape: RoundedRectangleBorder(<br>                                borderRadius: BorderRadius.circular(6))),<br>                        onPressed: () {<br>                          setState(() {<br>                            deleteData();<br>                          });<br>                        },<br>                        child: const Text(<br>                          &quot;DELETE&quot;,<br>                          style: TextStyle(color: Colors.white),<br>                        )),<br>                  ),<br>                ),</pre><p>The full codes can be seen below.</p><pre>import &#39;dart:convert&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:http/http.dart&#39; as http;<br>import &#39;package:http_example/other_methods.dart&#39;;<br>void main() {<br>  runApp(const MaterialApp(<br>    debugShowCheckedModeBanner: false,<br>    <br>    home: MyApp()));<br>}<br>class MyApp extends StatefulWidget {<br>  const MyApp({super.key});<br>  @override<br>  State&lt;MyApp&gt; createState() =&gt; _MyAppState();<br>}<br>class Dogmodel {<br>  final List message;<br>  var dogRange = List;<br>  Dogmodel({required this.message});<br>  factory Dogmodel.fromJson(dynamic json) {<br>    return Dogmodel(message: json[&#39;message&#39;] as List);<br>  }<br>}<br>class _MyAppState extends State&lt;MyApp&gt; {<br>  Future&lt;Dogmodel&gt; getDog() async {<br>    final response =<br>        await http.get(Uri.parse(&#39;https://dog.ceo/api/breed/beagle/images&#39;));<br>    if (response.statusCode == 200) {<br>      return Dogmodel.fromJson(jsonDecode(response.body));<br>    } else {<br>      throw Exception(&quot;could not fetch data&quot;);<br>    }<br>  }<br>  late Future&lt;Dogmodel&gt; get;<br>  @override<br>  void initState() {<br>    super.initState();<br>    get = getDog();<br>  }<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      debugShowCheckedModeBanner: false,<br>     <br>      home: Scaffold(<br>        appBar: AppBar(<br>              actions: [<br>                Padding(<br>                  padding: const EdgeInsets.all(8.0),<br>                  child: ElevatedButton(<br>                    style: ElevatedButton.styleFrom(backgroundColor: Colors.purpleAccent,shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(6))),<br>                      onPressed: () {<br>                        Navigator.push(context, MaterialPageRoute(builder: (BuildContext context)=&gt; const OtherMethods()));<br>                      }, child: const Text(&quot;Other Methods&quot;,style: TextStyle(color: Colors.white),)),<br>                )<br>              ],),<br>        body: Center(<br>          child: FutureBuilder&lt;Dogmodel&gt;(<br>              future: get,<br>              builder: (context, snapshot) {<br>                if (snapshot.connectionState == ConnectionState.waiting) {<br>                  return const CircularProgressIndicator();<br>                } else if (snapshot.hasData) {<br>                 <br>                  List dogRange = snapshot.data!.message.sublist(0, 10);<br>                  int dogRangelen = dogRange.length;<br>                  <br>                  return ListView.builder(<br>                      itemCount: dogRangelen,<br>                      itemBuilder: (context, index) {<br>                        return Column(<br>                          children: [<br>                            Card(<br>                              margin: const EdgeInsets.all(8.0),<br>                              elevation: 4,<br>                              shape: const RoundedRectangleBorder(<br>                                  borderRadius:<br>                                      BorderRadius.all(Radius.circular(6))),<br>                              child: Padding(<br>                                padding: const EdgeInsets.all(8.0),<br>                                child: Column(<br>                                  children: [<br>                                    Image.network(<br>                                        snapshot.data!.message[index]),<br>                                  ],<br>                                ),<br>                              ),<br>                            ),<br>                            <br>                          ],<br>                        );<br>                      });<br>                } else {<br>                  print(&quot;Error: ${snapshot.error}&quot;);<br>                  throw Exception(&quot;Could not fetch data&quot;);<br>                }<br>              }),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><pre>import &#39;dart:convert&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:http/http.dart&#39; as http;<br>class OtherMethods extends StatefulWidget {<br>  const OtherMethods({super.key});<br>  @override<br>  State&lt;OtherMethods&gt; createState() =&gt; _OtherMethodsState();<br>}<br>class Datamodel {}<br>class _OtherMethodsState extends State&lt;OtherMethods&gt; {<br>  @override<br>  Widget build(BuildContext context) {<br>    <br>   <br>    return SafeArea(<br>      child: Scaffold(<br>        body: Center(<br>          child: Padding(<br>            padding: const EdgeInsets.all(12.0),<br>            child: Column(<br>              mainAxisAlignment: MainAxisAlignment.center,<br>              children: [<br>                Padding(<br>                  padding: const EdgeInsets.all(8.0),<br>                  child: SizedBox(<br>                    width: double.maxFinite,<br>                    child: ElevatedButton(<br>                        style: ElevatedButton.styleFrom(<br>                            backgroundColor: Colors.purpleAccent,<br>                            shape: RoundedRectangleBorder(<br>                                borderRadius: BorderRadius.circular(6))),<br>                        onPressed: () {<br>                          setState(() {<br>                            postData();<br>                          });<br>                        },<br>                        child: const Text(<br>                          &quot;POST&quot;,<br>                          style: TextStyle(color: Colors.white),<br>                        )),<br>                  ),<br>                ),<br>                Padding(<br>                  padding: const EdgeInsets.all(8.0),<br>                  child: SizedBox(<br>                    width: double.maxFinite,<br>                    child: ElevatedButton(<br>                        style: ElevatedButton.styleFrom(<br>                            backgroundColor: Colors.purpleAccent,<br>                            shape: RoundedRectangleBorder(<br>                                borderRadius: BorderRadius.circular(6))),<br>                        onPressed: () {<br>                          setState(() {<br>                            deleteData();<br>                          });<br>                        },<br>                        child: const Text(<br>                          &quot;DELETE&quot;,<br>                          style: TextStyle(color: Colors.white),<br>                        )),<br>                  ),<br>                ),<br>                Padding(<br>                  padding: const EdgeInsets.all(8.0),<br>                  child: SizedBox(<br>                    width: double.maxFinite,<br>                    child: ElevatedButton(<br>                        style: ElevatedButton.styleFrom(<br>                            backgroundColor: Colors.purpleAccent,<br>                            shape: RoundedRectangleBorder(<br>                                borderRadius: BorderRadius.circular(6))),<br>                        onPressed: () {<br>                          setState(() {<br>                            putData();<br>                          });<br>                        },<br>                        child: const Text(<br>                          &quot;PUT&quot;,<br>                          style: TextStyle(color: Colors.white),<br>                        )),<br>                  ),<br>                ),<br>              ],<br>            ),<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>Future&lt;void&gt; postData() async {<br>      var response = await http.post(<br>          Uri.parse(&#39;https://jsonplaceholder.typicode.com/posts&#39;),<br>          headers: {&quot;content-type&quot;: &quot;application/json&quot;},<br>          body: jsonEncode({<br>            &quot;userId&quot;: &#39;2&#39;,<br>            &quot;title&quot;: &#39;Introduction to API&#39;,<br>            &quot;body&quot;: &#39;This is just a demo of what you can do&#39;<br>          }));<br>      if (response.statusCode == 201) {<br>        ScaffoldMessenger.of(context).showSnackBar(const SnackBar(<br>          behavior: SnackBarBehavior.floating,<br>          backgroundColor: Color.fromARGB(255, 122, 245, 126),<br>          duration: Duration(seconds: 7),<br>          content: Text(&quot;Post Created Successfuly&quot;),<br>          shape: RoundedRectangleBorder(<br>              borderRadius: BorderRadius.all(Radius.circular(36))),<br>          showCloseIcon: true,<br>          dismissDirection: DismissDirection.horizontal,<br>          closeIconColor: Colors.white,<br>        ));<br>      } else {<br>        ScaffoldMessenger.of(context).showSnackBar(const SnackBar(<br>          behavior: SnackBarBehavior.floating,<br>          content: Row(<br>            children: [<br>              Icon(<br>                Icons.warning_amber,<br>                color: Colors.yellow,<br>              ),<br>              SizedBox(<br>                width: 18,<br>              ),<br>              Text(&quot;Something went wrong!&quot;)<br>            ],<br>          ),<br>          backgroundColor: Colors.red,<br>        ));<br>        throw Exception(&quot;Could not Post Data&quot;);<br>      }<br>    }<br>  Future&lt;void&gt; deleteData() async {<br>      var response = await http<br>          .delete(Uri.parse(&#39;https://jsonplaceholder.typicode.com/posts/${3}&#39;));<br>      if (response.statusCode == 200) {<br>        ScaffoldMessenger.of(context).showSnackBar(const SnackBar(<br>          behavior: SnackBarBehavior.floating,<br>          backgroundColor: Colors.green,<br>          duration: Duration(seconds: 7),<br>          content: Text(&quot;Post delete Success&quot;),<br>          shape: RoundedRectangleBorder(<br>              borderRadius: BorderRadius.all(Radius.circular(36))),<br>          showCloseIcon: true,<br>          dismissDirection: DismissDirection.horizontal,<br>          closeIconColor: Colors.white,<br>        ));<br>      } else {<br>        ScaffoldMessenger.of(context).showSnackBar(const SnackBar(<br>          behavior: SnackBarBehavior.floating,<br>          content: Row(<br>            children: [<br>              Icon(<br>                Icons.warning_amber,<br>                color: Colors.yellow,<br>              ),<br>              SizedBox(<br>                width: 18,<br>              ),<br>              Text(&quot;Something went wrong!&quot;)<br>            ],<br>          ),<br>          backgroundColor: Colors.red,<br>        ));<br>        throw Exception(&quot;Could not delete Data&quot;);<br>      }<br>    }<br>    <br>    Future&lt;void&gt; putData() async {<br>      var response = await http.put(<br>          Uri.parse(&#39;https://jsonplaceholder.typicode.com/posts/2&#39;),<br>          headers: {&quot;content-type&quot;: &quot;application/json&quot;},<br>          body: jsonEncode({<br>            &quot;userId&quot;: &#39;2&#39;,<br>            &quot;title&quot;: &#39;Introduction to API&#39;,<br>            &quot;body&quot;:<br>                &#39;You have learnt some of these concepts now is the time to apply them.&#39;<br>          }));<br>      if (response.statusCode == 200) {<br>        ScaffoldMessenger.of(context).showSnackBar(const SnackBar(<br>          behavior: SnackBarBehavior.floating,<br>          backgroundColor: Color.fromARGB(255, 122, 245, 126),<br>          duration: Duration(seconds: 7),<br>          content: Text(&quot;Post Updated Successfuly&quot;),<br>          shape: RoundedRectangleBorder(<br>              borderRadius: BorderRadius.all(Radius.circular(36))),<br>          showCloseIcon: true,<br>          dismissDirection: DismissDirection.horizontal,<br>          closeIconColor: Colors.white,<br>        ));<br>      } else {<br>        ScaffoldMessenger.of(context).showSnackBar(const SnackBar(<br>          behavior: SnackBarBehavior.floating,<br>          content: Row(<br>            children: [<br>              Icon(<br>                Icons.warning_amber,<br>                color: Colors.yellow,<br>              ),<br>              SizedBox(<br>                width: 18,<br>              ),<br>              Text(&quot;Something went wrong!&quot;)<br>            ],<br>          ),<br>          backgroundColor: Colors.red,<br>        ));<br>        throw Exception(&quot;Could not update Data&quot;);<br>      }<br>    }<br>}</pre><p>You can then run the app by using the below command in your terminal.</p><pre>flutter run</pre><h3>Final Output</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*qXTb7sxOWR1pBveIZOWUDQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*gFc4JwUrfDXPbp4QiB7t9g.png" /></figure><h3>Conclusion</h3><p>You have successfully learned how to use the HTTP methods to implement API calls from two different endpoints, where we implemented the get, post, put, and delete methods in Flutter, and also learned how to build an asynchronous function with an approach that is suitable for a beginner. Thanks for reading.</p><p>You can check out the full code on <a href="https://github.com/oriohac/http_example">GitHub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4e93952aa29" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Send Multiple Twilio SMS Using Java]]></title>
            <link>https://medium.com/@oriohac/how-to-send-multiple-twilio-sms-using-java-da8430a9df9f?source=rss-bb7a8c9b98b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/da8430a9df9f</guid>
            <dc:creator><![CDATA[Chikezirim Orioha]]></dc:creator>
            <pubDate>Tue, 08 Mar 2022 16:54:34 GMT</pubDate>
            <atom:updated>2022-03-08T16:54:34.817Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*I5EiIhAmztbcIkJ6bzTeqw.jpeg" /></figure><p>SMS plays an important role in many organizations, as over the years it has proven to be a cost-effective medium for communication, easy to personalize, efficient, and widespread adoption by many, as nearly everyone has a cellphone, which makes the use of SMS for communication an easy one, to this effect, sending out SMS to multiple users with ease and without being blocked for spamming is an added advantage to organizations who have the advantage to reach people living in remote areas, and also to a large audience.</p><p>In this article, you will learn how to set up a free Twilio account and, using Java, send multiple Twilio SMS.</p><p>By the end of this article</p><p>• You will learn how to create a free Twilio account.</p><p>• Get your first Twilio-powered phone number.</p><p>• Set up your development environment.</p><p>• Send your first Twilio SMS.</p><p>• You will learn how to send multiple Twilio SMS using Java</p><p>Prerequisites</p><p>To achieve this, you will need the following tools:</p><ul><li>A computer: for this guide, I am using a window 10 pro powered device.</li><li>An installation of Java 8 or newer version–<a href="https://www.oracle.com/java/technologies/downloads/#java8">from Oracle</a>.</li><li>A Twilio account–<a href="https://www.twilio.com/referral/sQCFey">you can sign up for a free account here if you have not signed up yet and receive a $10 credit when you upgrade.</a></li><li>A Java IDE (Integrated Development Environment)–I like <a href="https://netbeans.apache.org/download/nb126/nb126.html">Apache NetBeans IDE</a>, but there is no problem if you have another IDE.</li></ul><p>To get started, create a free <a href="https://www.twilio.com/referral/sQCFey">Twilio account</a> by filling the form of sign in, with your first name, surname, email and a 16 digit password:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gqmVXZQF0ziOjDHTyNVzcA.png" /></figure><p>Then fill out the form below to personalize your experience on Twilio, stating the Twilio product you want to make use of, like SMS, call, WhatsApp and more, but in our case, we want to send SMS using Java.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*9p8AKc-xSnao5DcV73Z8rA.png" /></figure><p>Once you have filled the form above and clicked on the “Get Started with Twilio” button, then you have successfully created a free Twilio account.</p><p>Explore your Twilio console and see some functions that can be carried out on the console:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*E5Xjf6_Kf_XD_xc9E_g-RQ.png" /></figure><p>The next thing to do is to get a trial phone number. This will enable you to send SMS, and you can generate the USA or a Canada number on a free trial. To get a local phone number out of Canada or USA, upgrade your account and also meet the regulatory requirements of the specified country.</p><p>To get a trial phone number, click on the “Get a trial phone number” button and wait for it to generate a number, then you are ready to carry out operations using your Twilio’s generated number:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*QLUrw4yRIKtYqjkQcVrqSA.png" /></figure><p>To see your newly generated number, and other credentials like your Account SID and Auth Token, scroll down the console where you will see account information, click on the drop-down of Account Info to see this information which will be used from time to time as we proceed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*nL_wtsHwhPRaUb0Ty5PzCA.png" /></figure><p>On the left menu click on messaging to set up your Twilio message platform, with the steps below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*wW8Xzx9dHtUSSqEENGDIpw.png" /></figure><p>Click the start setup button to set up messaging on the Twilio dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*_Vy5l4wfCsoZK5-bKl-qJQ.png" /></figure><p>Choose a messaging service by naming the messaging service to whatever name you want to give it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*R01cyEE976F_yEW1t-qc5w.png" /></figure><p>Then provide the phone number you generated on Twilio and click on the “Add this number” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*U-rjd41QGpCrfY9ut3I-Nw.png" /></figure><p>With I completed these steps, you have successfully set up your free Twilio account and are ready to send your first SMS using the Twilio platform on windows powered device.</p><p>Now you have successfully set up your message dashboard on Twilio. The next step is to try out the SMS platform.</p><p><strong>Sending your first SMS using Java:</strong></p><p>Create a new project in your IDE and give it a preferable name. With your SID and Auth Token, edit the code below and run.</p><p>// Install the Java helper library from twilio.com/docs/java/install</p><p>import com.twilio.Twilio;</p><p>import com.twilio.rest.api.v2010.account.Message;</p><p>import com.twilio.type.PhoneNumber;</p><p>public class Example {</p><p>// Find your Account SID and Auth Token at twilio.com/console</p><p>// and set the environment variables. See <a href="http://twil.io/secure">http://twil.io/secure</a></p><p>public static final String ACCOUNT_SID = System.getenv(“TWILIO_ACCOUNT_SID”);</p><p>public static final String AUTH_TOKEN = System.getenv(“TWILIO_AUTH_TOKEN”);</p><p>public static void main(String[] args) {</p><p>Twilio.init(ACCOUNT_SID, AUTH_TOKEN);</p><p>Message message = Message.creator(</p><p>new com.twilio.type.PhoneNumber(“From Phone Number”),</p><p>new com.twilio.type.PhoneNumber(“To Phone number”),</p><p>“Where’s Wallace?”)</p><p>.create();</p><p>System.out.println(message.getSid());</p><p>}</p><p>}</p><p>Replace TWILIO_ACCOUNT_SID with your account SID, also replace TWILIO_AUTH_TOKEN with your Authentication token, then add the number you generated on Twilio to where “From Phone Number” is, also replace the “To Phone number” with the number you want to send the SMS to.</p><p>Note if you are using a trial account, you can only send messages to verified phone numbers as you can see below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*fBvNJ4fi9r0ipwP6-K9pBw.png" /></figure><p>You can click on the “Add a new Caller ID” button to add a newly verified user.</p><p>With these newly verified users, you can now send multiple SMS from Twilio.</p><p>To send messages to multiple users (also known as Notify), maybe your customers to notify them of a price change, you need to make available a list of recipients. AS Notify can send messages to different channels, then there is an abstraction called binding.</p><p>We can create bindings through either the API and call them when sending a message, or as you send, your messages provide the Bindings. We will make use of the second approach where we will provide the binding as we send our message, this entails the creation of a List&lt;String&gt; of Bindings as every entry will be like a short representation of JSON, which looks like {“binding_type”:”SMS”, “address”: NUMBER}. Many ways are available to achieve this, but the code below will serve the purpose:</p><pre>String bindingFormat = &quot;{\&quot;binding_type\&quot;: \&quot;sms\&quot;, \&quot;address\&quot;: \&quot;%s\&quot;}&quot;;</pre><pre>List&lt;String&gt; bindings = Stream.of(</pre><pre>&quot;Recipient Phone Number #1&quot;,</pre><pre>&quot;Recipient Phone Number #2&quot;,</pre><pre>&quot;Recipient Phone Number #3&quot; // and more users as you like</pre><pre>)</pre><pre>.map(phoneNumber -&gt; String.format(bindingFormat, phoneNumber))</pre><pre>.collect(Collectors.toList());</pre><pre>Notification notification = Notification.creator(</pre><pre>System.getenv(&quot;TWILIO_NOTIFY_SERVICE_SID&quot;))</pre><pre>.setToBinding(bindings)</pre><pre>.setBody(&quot;Twilio Multiple SMS Sent through java, and single API request&quot;)</pre><pre>.create();</pre><p>About 10,000 bindings are safe for a single request, and you should split the bindings across multiple requests when it exceeds 10,000 bindings, as the limit for the number of recipients is up to 1Mb limit on HTTP requests for Twilio API.</p><p><strong>Rounding Up:</strong></p><p>You have learnt how to create a Twilio account, set it up and send your first message programmatically using java. Also, you have learnt how to send multiple SMS using Java binding. If you have questions about any of these steps, do not forget to state where you became confused.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da8430a9df9f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>