<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Sudhanshu Kumar Yadav</title>
    <description>The latest articles on Forem by Sudhanshu Kumar Yadav (@sky1095).</description>
    <link>https://forem.com/sky1095</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F70785%2F138cb815-9414-4a1f-86be-ba19010390e9.jpeg</url>
      <title>Forem: Sudhanshu Kumar Yadav</title>
      <link>https://forem.com/sky1095</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sky1095"/>
    <language>en</language>
    <item>
      <title>Deferred Deep Linking: How it works internally 🕵️</title>
      <dc:creator>Sudhanshu Kumar Yadav</dc:creator>
      <pubDate>Mon, 19 Aug 2024 15:03:12 +0000</pubDate>
      <link>https://forem.com/sky1095/deferred-deep-linking-how-it-works-internally-1l1a</link>
      <guid>https://forem.com/sky1095/deferred-deep-linking-how-it-works-internally-1l1a</guid>
      <description>&lt;p&gt;As a senior professional, implementing deferred deep linking in numerous applications, I will slice the internal mechanisms operating under the hood to make this functionality possible in both Android and iOS. We will look through the system APIs and processes followed by the attribution services such as Branch or AppsFlyer that make this very capability of deferred deep linking possible.&lt;/p&gt;

&lt;p&gt;Android Internals&lt;/p&gt;

&lt;p&gt;Key sections of how Deferred Deep Linking is implemented within Android are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install Referrer API:
This API is critical to the Deferred Deep Linking flow. It allows the app to query information regarding the referrer upon installing a new app from the Play store.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Key API: &lt;code&gt;com.android.installreferrer.api.InstallReferrerClient&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;How it works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;client&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;InstallReferrerClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;newBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startConnection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;object&lt;/span&gt; &lt;span class="err"&gt;: &lt;/span&gt;&lt;span class="nc"&gt;InstallReferrerStateListener&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;onInstallReferrerSetupFinished&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;responseCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;when&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;responseCode&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nc"&gt;InstallReferrerClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;InstallReferrerResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;OK&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;response&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;referrerClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;installReferrer&lt;/span&gt;
                &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;referrerUrl&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;installReferrer&lt;/span&gt;
&lt;span class="c1"&gt;// Process the referrer URL&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="c1"&gt;// Handle other response codes&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;onInstallReferrerServiceDisconnected&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;// Handle disconnection&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The structure of the information is embedded in the referrer URL.&lt;br&gt;
The referrer URL can be well formed using some encoded information for a deep link.&lt;br&gt;
Attribution tools can decode this information.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Content Providers:
Usually, Attribution SDKs use Content Providers to save information and read it between app starts:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;DeepLinkProvider&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ContentProvider&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Uri&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;projection&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;?,&lt;/span&gt; &lt;span class="n"&gt;selection&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;?,&lt;/span&gt;
&lt;span class="n"&gt;selectionArgs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;?,&lt;/span&gt; &lt;span class="n"&gt;sortOrder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;?):&lt;/span&gt; &lt;span class="nc"&gt;Cursor&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Implement query to retrieve stored deep link data&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;// Implement other ContentProvider methods&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;INSTALL_REFERRER Broadcast:
Android, upon app installation, fires a broadcast intent called INSTALL_REFERRER. We can intercept this broadcast and retrieve information about the installation.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;InstallReferrerReceiver&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;BroadcastReceiver&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;onReceive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;intent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Intent&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;intent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;action&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="s"&gt;"com.android.vending.INSTALL_REFERRER"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;referrerString&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;intent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getStringExtra&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"referrer"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// Process referrer string&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;iOS Internals&lt;/p&gt;

&lt;p&gt;On iOS, the process relies on some features of the system:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Universal Links:
iOS works with Universal Links which build on Associated Domains Entitlement. It enables claiming the ownership of certain web domains an app owns.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Key API: &lt;code&gt;UIApplicationDelegate&lt;/code&gt; methods&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;application&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="nv"&gt;application&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;UIApplication&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="k"&gt;continue&lt;/span&gt; &lt;span class="nv"&gt;userActivity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;NSUserActivity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                 &lt;span class="nv"&gt;restorationHandler&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;@escaping&lt;/span&gt; &lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="kt"&gt;UIUserActivityRestoring&lt;/span&gt;&lt;span class="p"&gt;]?)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;Void&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;Bool&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;incomingURL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;userActivity&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;webpageURL&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Process the incoming URL&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;SKStoreProductViewController:
The majority of attribution services take advantage of &lt;code&gt;SKStoreProductViewController&lt;/code&gt; to send users to the App Store but retain context in deferred scenarios.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;import&lt;/span&gt; &lt;span class="kt"&gt;StoreKit&lt;/span&gt;

&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;storeViewController&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;SKStoreProductViewController&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;storeViewController&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;loadProduct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;withParameters&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;SKStoreProductParameterITunesItemIdentifier&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;appId&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;success&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;success&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;present&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;storeViewController&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;animated&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;App Clip Experiences
While this isn't directly relevant to deferred deep linking, because App Clips allow functionality to be offered even before complete installation, that functionality can be used to provide a much more seamless d experience.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Key API: &lt;code&gt;NSUserActivity&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The Info.plist :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;userActivity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;userActivity&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="c1"&gt;// Handle the user activity, which might contain deep link info  handleUserActivity(userActivity)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;KeyChain and UserDefaults
These are the storage mechanisms used in iOS for the saving of deep link data for launches and installations.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;import&lt;/span&gt;  &lt;span class="kt"&gt;Security&lt;/span&gt;

&lt;span class="kd"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;storeDeepLinkData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="nv"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Any&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="n"&gt;kSecClass&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;kSecClassGenericPassword&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;kSecAttrAccount&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"DeepLinkData"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;kSecValueData&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="kt"&gt;SecItemAdd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kt"&gt;CFDictionary&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Attribution Service Integration&lt;/p&gt;

&lt;p&gt;Platforms like Branch and AppsFlyer take advantage of these platform-specific mechanisms even further:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;They utilize the Install Referrer API and broadcast receivers in Android and the Universal Links iOS to grasp install and deep link data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;They apply server-side storage to maintain deep link data sandwiched between the initial click and app open.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;They offer SDKs that take care of this plumped up complexity, offering the same developers a smooth unified API.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Key Considerations&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Timing and Race Conditions: Both platforms require stable handling of situations in which app initialization and deep link data resolution may occur in a different order.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Privacy and Data Retention: With increased scrutiny in this area, responsible data handling for users' data in line with regulation, and not least GDPR and CCPA.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is because of its complex nature, which would require thorough testing under all possible scenarios: from a fresh install, reopening, and time delay.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;/p&gt;

&lt;p&gt;Deferred deep linking cannot simply be explained as advanced functionality, implemented over a mix of APIs native to the OS, infrastructure necessary for attribution services, and of course, implemented meticulously. Such insight helps us be more resilient and reduces the resources that deep linking actually brings to bear into our apps—user acquisition and engagement.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Loop Labels: The Unsung Heroes</title>
      <dc:creator>Sudhanshu Kumar Yadav</dc:creator>
      <pubDate>Thu, 01 Jun 2023 19:37:50 +0000</pubDate>
      <link>https://forem.com/sky1095/loop-labels-the-unsung-heroes-36o2</link>
      <guid>https://forem.com/sky1095/loop-labels-the-unsung-heroes-36o2</guid>
      <description>&lt;p&gt;&lt;strong&gt;Picture this:&lt;/strong&gt; you're a maestro conducting an orchestra of nested loops. Each instrument has its own loop, its own rhythm, but sometimes, the tuba needs to take a pause. That's where the power of Dart's loop labelling enters stage right. It's the equivalent of a conductor's baton, directing which section needs to continue and which needs a breather.&lt;/p&gt;

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

&lt;p&gt;Loop labels are like secret agents. They're often overlooked, but when you need them, they swoop in and save the day. And in Dart, they can be your best friend in the wild, wild west of nested loops.&lt;/p&gt;

&lt;p&gt;Imagine you're in charge of a system for a school district. You need to search across multiple schools, each with multiple classes and students, to find a particular student based on their name. Suppose that a student could be temporarily marked as inactive in a class if they are absent. We will check the status of the student and act accordingly:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;If we find the student and they are enrolled and active, we'll break all loops as we're done with our search.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If we find the student and they are enrolled but inactive, we'll break the current student loop and continue with the next student in the same class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If we find the student but they're not enrolled, we'll break the current class loop and continue with the next class or school.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void main() {
  var district = {
    'School A': {
      'Class 1': [{'name': 'Alice', 'enrolled': true, 'active': true}, {'name': 'Bob', 'enrolled': false, 'active': false}, {'name': 'Charlie', 'enrolled': true, 'active': true}],
      'Class 2': [{'name': 'Daniel', 'enrolled': true, 'active': true}, {'name': 'Eva', 'enrolled': true, 'active': true}, {'name': 'Frank', 'enrolled': false, 'active': true}],
    },
    'School B': {
      'Class 1': [{'name': 'Grace', 'enrolled': true, 'active': true}, {'name': 'Hannah', 'enrolled': true, 'active': true}, {'name': 'Ian', 'enrolled': true, 'active': true}],
      'Class 2': [{'name': 'Frank', 'enrolled': true, 'active': false}, {'name': 'Katie', 'enrolled': true, 'active': true}, {'name': 'Laura', 'enrolled': true, 'active': true}],
    },
    // Imagine there are many more schools and classes
  };

  var searchStudent = 'Frank';

  schoolLoop: for (var school in district.keys) {
    classLoop: for (var className in district[school].keys) {
      studentLoop: for (var student in district[school][className]) {
        if (student['name'] == searchStudent) {
          if (student['enrolled']) {
            if (student['active']) {
              print('Found $searchStudent active and enrolled in $className of $school!');
              break schoolLoop;
            } else {
              print('Found $searchStudent enrolled but inactive in $className of $school.');
              break studentLoop;
            }
          } else {
            print('Found $searchStudent not currently enrolled in $className of $school.');
            break classLoop;
          }
        }
      }
    }
  }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a neat trick that can save computing power and make your programs more efficient. In real-life scenarios, you might have more complex conditions, more nested loops, or other operations, but the principle remains the same. By judiciously using loop labels in Dart, you can write cleaner, more efficient, and more readable code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping It Up
&lt;/h2&gt;

&lt;p&gt;Labels, in essence, give you the power to break free from not just one loop, but a whole set of them. It's like having a golden ticket that lets you exit the amusement park whenever you want. No need to take the monorail all the way around just to reach the exit!&lt;/p&gt;

&lt;p&gt;But remember, with great power comes great responsibility. Don't go breaking loops willy-nilly. Only do so when it's truly needed.&lt;/p&gt;

</description>
      <category>dart</category>
      <category>flutter</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Do you know the patterns?</title>
      <dc:creator>Sudhanshu Kumar Yadav</dc:creator>
      <pubDate>Tue, 23 May 2023 20:01:35 +0000</pubDate>
      <link>https://forem.com/sky1095/do-you-know-the-patterns-2e91</link>
      <guid>https://forem.com/sky1095/do-you-know-the-patterns-2e91</guid>
      <description>&lt;p&gt;Hello fellow Dartisans! I hope you're ready for an exciting journey into the heart of Dart 3.0. Released on 10th May 2023, this version introduced a flock of major language features: Patterns, Records, and Class Modifiers​​. So buckle up, because we're about to dive in and explore these features with some fun examples.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Patterns&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Patterns, in Dart, serve as a new category of grammar. They allow you to match and destructure values, enabling the extraction of parts of an object's data in an easy and intuitive way. Let's see some of the examples I have been trying out since my B'day.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Extracting Information from a List&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;numList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;numList&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Prints 6&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we're using a list pattern to destructure the three elements from &lt;code&gt;numList&lt;/code&gt; and assign them to new variables &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt;, and &lt;code&gt;c&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Swapping Variables&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'left'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'right'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Swap.&lt;/span&gt;
&lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="si"&gt;$a&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="si"&gt;$b&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Prints "right left"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, a pattern is used to swap the values of two variables without declaring a third temporary one.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Destructuring Map Entries&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kt"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;hist&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s"&gt;'a'&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;23&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s"&gt;'b'&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;MapEntry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;value:&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;hist&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;entries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="si"&gt;$key&lt;/span&gt;&lt;span class="s"&gt; occurred &lt;/span&gt;&lt;span class="si"&gt;$count&lt;/span&gt;&lt;span class="s"&gt; times'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, an object pattern is used in a for-in loop to destructure the &lt;code&gt;MapEntry&lt;/code&gt; objects that a &lt;code&gt;&amp;lt;Map&amp;gt;.entries&lt;/code&gt; call returns, effectively iterating over the entries of a map.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Validating and Extracting JSON Data&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s"&gt;'user'&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'Lily'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt; &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;'user'&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;]})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'User &lt;/span&gt;&lt;span class="si"&gt;$name&lt;/span&gt;&lt;span class="s"&gt; is &lt;/span&gt;&lt;span class="si"&gt;$age&lt;/span&gt;&lt;span class="s"&gt; years old'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, a case pattern is used to validate and destructure a JSON object. If the object has the expected structure, the pattern destructures it into local variables, providing a declarative and less verbose way of handling JSON data.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>mobile</category>
      <category>programming</category>
    </item>
    <item>
      <title>Flutter on Top: Elevate Your App to the macOS Status Bar</title>
      <dc:creator>Sudhanshu Kumar Yadav</dc:creator>
      <pubDate>Tue, 16 May 2023 20:08:46 +0000</pubDate>
      <link>https://forem.com/sky1095/flutter-on-top-elevate-your-app-to-the-macos-status-bar-1lfh</link>
      <guid>https://forem.com/sky1095/flutter-on-top-elevate-your-app-to-the-macos-status-bar-1lfh</guid>
      <description>&lt;p&gt;Hello, fellow Flutter enthusiasts! 🎉&lt;/p&gt;

&lt;p&gt;Today, we're going to dive into something truly magical. We're going to take a Flutter app and make it run in the macOS status bar. Yes, you read that right! We're going to take our Flutter prowess to the next level and make our apps even more accessible and user-friendly. So, buckle up, and let's get started! 🚀&lt;/p&gt;

&lt;h2&gt;
  
  
  Flutter Meets macOS Status Bar
&lt;/h2&gt;

&lt;p&gt;First things first, let's talk about why you might want to run your Flutter app in the macOS status bar. The status bar is that nifty little area at the top of your screen that houses useful information and quick access to system functions. It's always visible, making it a prime real estate for apps that users need to access frequently.&lt;/p&gt;

&lt;p&gt;Imagine having a mini weather app, a quick note-taking app, or a system monitor right there in the status bar. Sounds cool, right? Well, with Flutter, we can make it happen!&lt;/p&gt;

&lt;h2&gt;
  
  
  The Magic Begins
&lt;/h2&gt;

&lt;p&gt;To get started, we need to set up our Flutter project. If you're new to Flutter, check out the &lt;a href="https://flutter.dev/docs/get-started/install" rel="noopener noreferrer"&gt;official Flutter installation guide&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;flutter create flutter_statusbar_app
&lt;span class="nb"&gt;cd &lt;/span&gt;flutter_statusbar_app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, we're going to dig a lil deeper in our brewed flutter project, head to &lt;code&gt;flutter_statusbar_app/macos/Runner/AppDelegate.swift&lt;/code&gt; file. You need to change it a bit with the below code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;import&lt;/span&gt; &lt;span class="kt"&gt;Cocoa&lt;/span&gt;
&lt;span class="kd"&gt;import&lt;/span&gt; &lt;span class="kt"&gt;FlutterMacOS&lt;/span&gt;

&lt;span class="kd"&gt;@NSApplicationMain&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="kt"&gt;AppDelegate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;FlutterAppDelegate&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Instance of the status bar controller&lt;/span&gt;
  &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;statusBarController&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;StatusBarController&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt;

  &lt;span class="c1"&gt;// Instance of the popover that will display the Flutter UI&lt;/span&gt;
  &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;flutterUIPopover&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;NSPopover&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="c1"&gt;// Initializer for the AppDelegate class&lt;/span&gt;
  &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Set the popover behavior to transient, meaning it will close when the user clicks outside of it&lt;/span&gt;
    &lt;span class="n"&gt;flutterUIPopover&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;behavior&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;NSPopover&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;Behavior&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transient&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;// Function to determine whether the application should terminate when the last window is closed&lt;/span&gt;
  &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="kd"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;applicationShouldTerminateAfterLastWindowClosed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="nv"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;NSApplication&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;Bool&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Return false to keep the application running even if all windows are closed&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;// Function called when the application has finished launching&lt;/span&gt;
  &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="kd"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;applicationDidFinishLaunching&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="nv"&gt;aNotification&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Notification&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Get the FlutterViewController from the main Flutter window&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;flutterViewController&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;FlutterViewController&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
      &lt;span class="n"&gt;mainFlutterWindow&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;contentViewController&lt;/span&gt; &lt;span class="k"&gt;as!&lt;/span&gt; &lt;span class="kt"&gt;FlutterViewController&lt;/span&gt;

    &lt;span class="c1"&gt;// Set the size of the popover&lt;/span&gt;
    &lt;span class="n"&gt;flutterUIPopover&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;contentSize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;NSSize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;360&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;360&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// Change this to your desired size&lt;/span&gt;

    &lt;span class="c1"&gt;// Set the content view controller for the popover to the FlutterViewController&lt;/span&gt;
    &lt;span class="n"&gt;flutterUIPopover&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;contentViewController&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;flutterViewController&lt;/span&gt;

    &lt;span class="c1"&gt;// Initialize the status bar controller with the popover&lt;/span&gt;
    &lt;span class="n"&gt;statusBarController&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;StatusBarController&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flutterUIPopover&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;// Close the default Flutter window as the Flutter UI will be displayed in the popover&lt;/span&gt;
    &lt;span class="n"&gt;mainFlutterWindow&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;// Call the superclass's applicationDidFinishLaunching function to perform any additional setup&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;applicationDidFinishLaunching&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;aNotification&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Import Statements: The import Cocoa and import FlutterMacOS statements are importing the necessary libraries for the macOS application and Flutter.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;AppDelegate Class: The AppDelegate class is a subclass of FlutterAppDelegate. This class is the entry point of the application and handles application-level events.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Variables: The statusBar variable is an instance of StatusBarController (not shown in this code snippet), which presumably manages the status bar item. The popover variable is an instance of NSPopover, which is a macOS UI component that displays content in a separate hovering window.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;init() Function: The init() function is the initializer for the AppDelegate class. Here, it sets the popover behavior to NSPopover.Behavior.transient, which means the popover will close when the user clicks outside of it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;applicationShouldTerminateAfterLastWindowClosed(_:) Function: This function determines whether the application should terminate when the last window is closed. It returns false, meaning the application will keep running even if all windows are closed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;applicationDidFinishLaunching(_:) Function: This function is called when the application has finished launching. It does several things:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;It gets the FlutterViewController from the mainFlutterWindow, which is the main window of the Flutter application.&lt;/li&gt;
&lt;li&gt;It sets the size of the popover and assigns its contentViewController to the FlutterViewController. This means the Flutter UI will be displayed in the popover.&lt;/li&gt;
&lt;li&gt;It initializes the statusBar with the popover, presumably creating a status bar item that shows the popover when clicked.&lt;/li&gt;
&lt;li&gt;It closes the mainFlutterWindow, as the Flutter UI will be displayed in the popover instead of the main window.&lt;/li&gt;
&lt;li&gt;It calls super.applicationDidFinishLaunching(aNotification), which calls the same function in the superclass (FlutterAppDelegate), performing any additional necessary setup.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now let's move to creating the &lt;code&gt;StatusBarController.swift&lt;/code&gt; file:&lt;/p&gt;

&lt;p&gt;For this open your &lt;code&gt;macos&lt;/code&gt; folder in Xcode. Goto file at the top: File -&amp;gt; New -&amp;gt; File -&amp;gt; Choose Swift File&lt;/p&gt;

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

&lt;blockquote&gt;
&lt;p&gt;N.B.: don't try to use shortcut and create this file from other code editor like VSCode.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;add the following magical code in the created file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;import&lt;/span&gt; &lt;span class="kt"&gt;AppKit&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="kt"&gt;StatusBarController&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Instance of the status bar&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;appStatusBar&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;NSStatusBar&lt;/span&gt;

    &lt;span class="c1"&gt;// Instance of the status bar item&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;statusBarMenuItem&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;NSStatusItem&lt;/span&gt;

    &lt;span class="c1"&gt;// Instance of the popover that will display the Flutter UI&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;flutterUIPopover&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;NSPopover&lt;/span&gt;

    &lt;span class="c1"&gt;// Initializer for the StatusBarController class&lt;/span&gt;
    &lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="nv"&gt;popover&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;NSPopover&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;flutterUIPopover&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;popover&lt;/span&gt;
        &lt;span class="n"&gt;appStatusBar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;NSStatusBar&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;statusBarMenuItem&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;appStatusBar&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;statusItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;withLength&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;28.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c1"&gt;// Configure the status bar item's button&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;statusBarMenuButton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;statusBarMenuItem&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// Set the button's image&lt;/span&gt;
            &lt;span class="n"&gt;statusBarMenuButton&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;#imageLiteral&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;resourceName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"AppIcon"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// Change this to your desired image&lt;/span&gt;
            &lt;span class="n"&gt;statusBarMenuButton&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;NSSize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;18.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;18.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;statusBarMenuButton&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isTemplate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;

            &lt;span class="c1"&gt;// Set the button's action to toggle the popover when clicked&lt;/span&gt;
            &lt;span class="n"&gt;statusBarMenuButton&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;action&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;#selector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;togglePopover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;:))&lt;/span&gt;
            &lt;span class="n"&gt;statusBarMenuButton&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;self&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Function to toggle the popover when the status bar item's button is clicked&lt;/span&gt;
    &lt;span class="kd"&gt;@objc&lt;/span&gt; &lt;span class="kd"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;togglePopover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;AnyObject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flutterUIPopover&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isShown&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nf"&gt;hidePopover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nf"&gt;showPopover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Function to show the popover&lt;/span&gt;
    &lt;span class="kd"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;showPopover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="nv"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;AnyObject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;statusBarMenuButton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;statusBarMenuItem&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;flutterUIPopover&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;show&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;relativeTo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;statusBarMenuButton&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bounds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;statusBarMenuButton&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;preferredEdge&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;NSRectEdge&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;maxY&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Function to hide the popover&lt;/span&gt;
    &lt;span class="kd"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;hidePopover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="nv"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;AnyObject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;flutterUIPopover&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;performClose&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't worry, we will break down this code blob too if it doesn't look familiar:&lt;/p&gt;

&lt;p&gt;This Swift code defines a class &lt;code&gt;StatusBarController&lt;/code&gt; that manages a status bar item for a macOS application. The status bar item is associated with a popover, which is a UI element that displays content in a separate window that appears above other content onscreen.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Import Statement&lt;/strong&gt;: &lt;code&gt;import AppKit&lt;/code&gt; imports the necessary library for working with the macOS user interface.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Class Definition&lt;/strong&gt;: &lt;code&gt;class StatusBarController&lt;/code&gt; defines the class. It has four properties: &lt;code&gt;statusBar&lt;/code&gt;, &lt;code&gt;statusItem&lt;/code&gt;, &lt;code&gt;popover&lt;/code&gt;, and &lt;code&gt;statusBarButton&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Initializer&lt;/strong&gt;: The &lt;code&gt;init(_ popover: NSPopover)&lt;/code&gt; function is the initializer for the class. It takes an &lt;code&gt;NSPopover&lt;/code&gt; as an argument and sets up the status bar and status bar item. The status bar item's button is configured with an image and an action that toggles the popover when clicked.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;togglePopover(sender: AnyObject) Function&lt;/strong&gt;: This function is called when the status bar item's button is clicked. It checks if the popover is shown and calls either &lt;code&gt;showPopover(_:)&lt;/code&gt; or &lt;code&gt;hidePopover(_:)&lt;/code&gt; accordingly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;showPopover(_ sender: AnyObject) Function&lt;/strong&gt;: This function shows the popover. It positions the popover relative to the status bar item's button.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;hidePopover(_ sender: AnyObject) Function&lt;/strong&gt;: This function hides the popover.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In summary, this class manages a status bar item that, when clicked, toggles a popover. The popover is positioned relative to the status bar item's button.&lt;/p&gt;




&lt;p&gt;That's all for the native side, moving to dart side 🎯 &lt;/p&gt;

&lt;p&gt;Run your &lt;code&gt;main.dart&lt;/code&gt; as macOS desktop target selected using;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;flutter run &lt;span class="nt"&gt;-d&lt;/span&gt; macos 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if you can't see macOS as an option in your available device list; &lt;br&gt;
run this command once&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;flutter config &lt;span class="nt"&gt;--enable-macos-desktop&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And voila! You've just created a Flutter app that runs in the macOS status bar! 🎉&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;Running a Flutter app in the macOS status bar opens up a world of possibilities. It allows you to create apps that are always accessible and provide real-time information or quick functionality. So go ahead, experiment, and create something amazing!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/sky1095/flutter_macos_statusbar" rel="noopener noreferrer"&gt;Checkout the repo for the complete project&lt;/a&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>swift</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Flutter's Hidden Treasures: Unearthing Rare Widgets and Their Use Cases 🗝️</title>
      <dc:creator>Sudhanshu Kumar Yadav</dc:creator>
      <pubDate>Sat, 06 May 2023 14:34:38 +0000</pubDate>
      <link>https://forem.com/sky1095/flutters-hidden-treasures-unearthing-rare-widgets-and-their-use-cases-31gn</link>
      <guid>https://forem.com/sky1095/flutters-hidden-treasures-unearthing-rare-widgets-and-their-use-cases-31gn</guid>
      <description>&lt;p&gt;Unlocking the secrets of lesser-known Flutter widgets and how to use them!&lt;/p&gt;




&lt;p&gt;Ahoy, Flutter adventurers! 👋&lt;/p&gt;

&lt;p&gt;Are you ready to embark on a thrilling adventure to uncover the hidden treasures of the Flutter widget universe? You've come to the right place! 🗺️ Join me as we shine a light on some of the rarely used widgets that might just turn out to be the secret weapons in your Flutter arsenal, today we will not only uncover hidden widget treasures but also explore their fascinating use cases! 🔍&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. IntrinsicWidth &amp;amp; IntrinsicHeight: Masters of Dimensions 📏&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Use Case:&lt;/em&gt;&lt;br&gt;
Suppose you're building a news app, and you have an article widget that displays a varying amount of text. To ensure that the widget sizes itself based on the content, you can use IntrinsicWidth and IntrinsicHeight:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;IntrinsicHeight&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;IntrinsicWidth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Container&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;decoration:&lt;/span&gt; &lt;span class="n"&gt;BoxDecoration&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;border:&lt;/span&gt; &lt;span class="n"&gt;Border&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;color:&lt;/span&gt; &lt;span class="n"&gt;Colors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
      &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s"&gt;'Breaking news: Flutter is awesome!'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nl"&gt;style:&lt;/span&gt; &lt;span class="n"&gt;TextStyle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;fontSize:&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Flow: The Artful Dodger 🎨&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Use Case:&lt;/em&gt;&lt;br&gt;
Imagine you're designing a photo editing app, and you want to create a custom layout for a set of filter icons that follow a curved path. You can use Flow and a custom FlowDelegate to achieve this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CurvedPathFlowDelegate&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;FlowDelegate&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;paintChildren&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;FlowPaintingContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;radius&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;iconSize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;childCount&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;theta&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;childCount&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;pi&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;radius&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;cos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;theta&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;iconSize&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;radius&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;sin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;theta&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;iconSize&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;paintChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;transform:&lt;/span&gt; &lt;span class="n"&gt;Matrix4&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;translationValues&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;shouldRepaint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CurvedPathFlowDelegate&lt;/span&gt; &lt;span class="n"&gt;oldDelegate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;Flow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;delegate:&lt;/span&gt; &lt;span class="n"&gt;CurvedPathFlowDelegate&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
  &lt;span class="nl"&gt;children:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="n"&gt;Icon&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Icons&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;filter_1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;size:&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;Icon&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Icons&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;filter_2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;size:&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;Icon&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Icons&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;filter_3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;size:&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. InteractiveViewer: The Pan and Zoom Prodigy 🔍&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Use Case:&lt;/em&gt;&lt;br&gt;
Let's say you're building a maps app, and you want to allow users to zoom in and pan around a map image. You can use InteractiveViewer to achieve this functionality:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;InteractiveViewer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;minScale:&lt;/span&gt; &lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;maxScale:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Image&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;network&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'https://example.com/map_image.jpg'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. DraggableScrollableSheet: The Shape-Shifting Scroller 📜&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Use Case:&lt;/em&gt;&lt;br&gt;
Imagine you're creating a ride-hailing app, and you want to display a draggable panel that reveals more information about a selected driver when expanded. You can use DraggableScrollableSheet to create this effect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;DraggableScrollableSheet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;initialChildSize:&lt;/span&gt; &lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;minChildSize:&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;maxChildSize:&lt;/span&gt; &lt;span class="mf"&gt;0.6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;builder:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ScrollController&lt;/span&gt; &lt;span class="n"&gt;scrollController&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;SingleChildScrollView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;controller:&lt;/span&gt; &lt;span class="n"&gt;scrollController&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;children:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
          &lt;span class="n"&gt;Icon&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Icons&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;drag_handle&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
          &lt;span class="n"&gt;ListTile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="nl"&gt;title:&lt;/span&gt; &lt;span class="s"&gt;"Text('Driver Name'),"&lt;/span&gt;
            &lt;span class="nl"&gt;subtitle:&lt;/span&gt; &lt;span class="s"&gt;"Text('4.8 ★'),"&lt;/span&gt;
          &lt;span class="p"&gt;),&lt;/span&gt;
          &lt;span class="c1"&gt;// Add more information about the driver here.&lt;/span&gt;
        &lt;span class="p"&gt;],&lt;/span&gt;
      &lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Placeholder: The Invisible Chameleon 🦎&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Use Case:&lt;/em&gt;&lt;br&gt;
Suppose you're building a social media app and are still working on the user profile section. Instead of displaying empty space, you can use a Placeholder widget to indicate where the profile picture will be placed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;Placeholder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;fallbackWidth:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;fallbackHeight:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,,&lt;/span&gt;
  &lt;span class="nl"&gt;strokeWidth:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;color:&lt;/span&gt; &lt;span class="n"&gt;Colors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;grey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. FractionallySizedBox: The Relative Sizer 🧙‍♂️&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;FractionallySizedBox is a magical widget that can resize its child based on a fraction of the parent's size. This wizardry allows you to create responsive layouts that gracefully adapt to different screen sizes and orientations.&lt;/p&gt;

&lt;p&gt;Use Case:&lt;br&gt;
Imagine you're building a responsive dashboard, andyou want a widget to always take up 70% of the screen width, regardless of the device's screen size. You can achieve this with a &lt;code&gt;FractionallySizedBox&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;FractionallySizedBox&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;widthFactor:&lt;/span&gt; &lt;span class="mf"&gt;0.7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;DashboardWidget&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7. ValueListenableBuilder: The Reactive Listener 🦻&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ValueListenableBuilder&lt;/code&gt; is like an attentive listener, always ready to react to changes in its &lt;code&gt;ValueListenable&lt;/code&gt; source. With this widget, you can efficiently rebuild only the parts of your UI that depend on a specific value, instead of rebuilding the entire widget tree.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Use Case:&lt;/em&gt;&lt;br&gt;
Suppose you have a counter app, and you want to display the current count without rebuilding the entire UI when the value changes. You can use a &lt;code&gt;ValueListenableBuilder&lt;/code&gt; to accomplish this and a great way to build the counter app without the Stateful Widget:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;ValueNotifier&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;counter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ValueNotifier&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="n"&gt;ValueListenableBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;valueListenable:&lt;/span&gt; &lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;builder:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Widget&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;child&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Counter: &lt;/span&gt;&lt;span class="si"&gt;$value&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;And that's a wrap, Flutter explorers! 🎉 We've embarked on an adventure through the lesser-known corners of the Flutter widget world, uncovering hidden gems and their fascinating use cases. Armed with this newfound knowledge, you can now create even more stunning and versatile user interfaces for your apps.&lt;/p&gt;

&lt;p&gt;Remember, the key to mastering Flutter lies in exploring and experimenting with different widgets. Don't be afraid to step out of your comfort zone and dive into the world of rare and unique widgets. Happy coding, and until our next adventure! 🚀💻&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>beginners</category>
      <category>mobile</category>
    </item>
    <item>
      <title>Flutter's Hidden Gems 💎: Unearthing Lesser-Known Facts</title>
      <dc:creator>Sudhanshu Kumar Yadav</dc:creator>
      <pubDate>Sat, 06 May 2023 13:54:32 +0000</pubDate>
      <link>https://forem.com/sky1095/flutters-hidden-gems-unearthing-lesser-known-facts-454j</link>
      <guid>https://forem.com/sky1095/flutters-hidden-gems-unearthing-lesser-known-facts-454j</guid>
      <description>&lt;p&gt;Greetings, &lt;del&gt;fellow&lt;/del&gt; flutter developers! 👋&lt;/p&gt;

&lt;p&gt;Today, we embark on an exciting journey to explore the uncharted territories of the Flutter framework. Flutter has taken the development world by storm, and as it turns out, there are hidden gems 💎 waiting to be discovered! Fasten your seatbelt and join me as we dig deep into the lesser-known facts about Flutter. 🔍&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. The Skia Connection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Did you know that Flutter's powerful rendering engine is actually powered by Skia, the same graphics library used by Chrome and Android? 🤯 That's right! This secret sauce is what enables Flutter to paint beautiful UIs on your screens with unparalleled performance. So the next time you're admiring your smooth, pixel-perfect Flutter app, remember to give a shoutout to Skia! 🙌&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. The Hummingbird Connection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Flutter's journey to the web is an interesting tale, reminiscent of a spy movie. In its initial days, the project was codenamed "Hummingbird." 🐦 Now, the project has blossomed into a full-fledged framework, Flutter for Web, allowing developers to create stunning web apps using the same Flutter magic! Talk about a transformation! 🦋&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. The Hidden Widgets&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Flutter is known for its extensive widget catalog, but there are a few widgets that like to play hide-and-seek! For example, the &lt;code&gt;LimitedBox&lt;/code&gt; widget limits its maximum size only when it's confined in a tight space. Perfect for those situations where you need a widget to know its boundaries, quite literally. 📏 Don't let these elusive widgets escape your notice! 😉&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. A Trip Down Memory Lane with Hot Reload&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you love Flutter's Hot Reload feature (and who doesn't?), you'll be intrigued to know that it's inspired by React Native's "Hot Module Replacement." But Flutter's team took it a step further, making it lightning-fast! ⚡️ Now you can witness your code changes come to life in real-time, making you feel like a wizard casting UI spells. 🧙‍♂️&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. The Flutter Time Machine&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Did you know that the first version of Flutter was actually called "Sky"? ☁️ Flutter's initial version was focused on providing a 120 FPS rendering experience for Android apps. But the Flutter we know today has evolved into a versatile, multi-platform powerhouse! 🚀&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. A Little Love for the Lesser-Known Dart&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Flutter's best-kept secret might be its language, Dart. While Dart might not have the same spotlight as some of its counterparts, it's an incredibly powerful and versatile language. With features like sound null safety and ahead-of-time (AOT) compilation, Dart plays an essential role in Flutter's awesomeness. Don't forget to show Dart some love, too! ❤️&lt;/p&gt;




&lt;p&gt;And there you have it, fellow explorers! 🌍 We've unveiled some of the hidden gems and lesser-known facts about the fantastic Flutter framework. May this knowledge add a sparkle to your Flutter journey as you continue to build stunning apps with newfound wisdom! 🌟&lt;/p&gt;

&lt;p&gt;Keep on Fluttering, and until next time, happy coding! 💻&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>mobile</category>
      <category>beginners</category>
    </item>
    <item>
      <title>🏰 Building the Perfect Sandcastle: A 5-Year-Old's Guide to Clean Architecture 🏰</title>
      <dc:creator>Sudhanshu Kumar Yadav</dc:creator>
      <pubDate>Fri, 05 May 2023 08:47:17 +0000</pubDate>
      <link>https://forem.com/sky1095/building-the-perfect-sandcastle-a-5-year-olds-guide-to-clean-architecture-41n6</link>
      <guid>https://forem.com/sky1095/building-the-perfect-sandcastle-a-5-year-olds-guide-to-clean-architecture-41n6</guid>
      <description>&lt;p&gt;Hey there, little architects! &lt;/p&gt;

&lt;p&gt;🌟 Have you ever built a sandcastle on the beach? 🏖️&lt;br&gt;
It takes time, patience, and the right techniques to create the perfect sandcastle. But did you know that building a sandcastle is a lot like building software? 🤯 Today, we're going to learn about "Clean Architecture" as if we're building a sandcastle, making it super fun and easy to understand! 🎉&lt;/p&gt;

&lt;p&gt;So, let's grab our buckets and shovels and start building! 🏰&lt;/p&gt;

&lt;h3&gt;
  
  
  Our Sandcastle: The Perfect Layers 🌈
&lt;/h3&gt;

&lt;p&gt;When we build a sandcastle, we need to make sure it has a strong foundation, so it doesn't fall apart. 🏗️ Similarly, in Clean Architecture, we create layers to make our software strong and easy to maintain. Let's look at the layers in our sandcastle:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Moat (Entities):&lt;/strong&gt; 🌊 The moat is the water surrounding our sandcastle. It protects our castle from intruders, just like "Entities" protect our software's core rules and logic. Entities are the most important part of our software, and they don't change much.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Walls (Use Cases):&lt;/strong&gt; 🏰 The walls of our sandcastle keep everything inside safe and organised. In Clean Architecture, we have "Use Cases" that keep our software's business logic safe and organised. Use Cases are like little workers that follow instructions to get things done.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Watchtowers (Gateways):&lt;/strong&gt; 👀 The watchtowers help us see what's happening outside our sandcastle. In software, "Gateways" are like watchtowers, as they help us communicate with the outside world, like databases or the internet. They're our little messengers! 📬&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Flags (Presenters):&lt;/strong&gt; 🚩 The flags on our sandcastle show everyone who we are and what we do. In Clean Architecture, "Presenters" are like flags, as they show the world what our software can do. Presenters take the results from our Use Cases and display them in a pretty way for users to see. 🌟&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Our Little Helpers: The Building Blocks 🧱
&lt;/h3&gt;

&lt;p&gt;Now that we have our layers, we need to connect them with some little helpers. In software, we call these helpers "dependencies." They're like the bridges and tunnels that connect different parts of our sandcastle. 🌉&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Bridges (Dependency Inversion):&lt;/strong&gt; 🌉 The bridges help us move between layers in our sandcastle. In Clean Architecture, we use "Dependency Inversion" to make our layers work together. This means that the lower layers depend on the higher layers, not the other way around. It keeps our sandcastle strong and flexible! 💪&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Tunnels (Dependency Injection):&lt;/strong&gt; 🚇 The tunnels help our little workers move between layers without anyone noticing. In software, we use "Dependency Injection" to give our layers the helpers they need to work together. It's like a secret passageway for our code! 🕵️‍♀️&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Wrapping Up: A Beautiful Sandcastle 🏰
&lt;/h3&gt;

&lt;p&gt;And that's it, little architects! 🎉 We've just built a beautiful sandcastle using the principles of Clean Architecture. By using layers, helpers, and the right techniques, we can make our software strong, flexible, and easy to maintain, just like a perfect sandcastle! 🌟&lt;/p&gt;

&lt;p&gt;So the next time you're building a sandcastle on the beach, remember that you're also practicing the art of Clean Architecture! 🏖️ With the right layers, little helpers, and techniques, you can create amazing software just like you create amazing sandcastles. 🎨&lt;/p&gt;

&lt;p&gt;Now go on and impress your friends, family, and even your favorite stuffed animals with your newfound knowledge of Clean Architecture! 🐻 Keep building, little architects, and never stop exploring the wonderful world of software development! 🚀&lt;/p&gt;

&lt;p&gt;Remember, practice makes perfect, and every sandcastle you build will make you a better architect in the world of software! 🏆 Happy building! 🏰✨&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>cleancode</category>
      <category>codenewbie</category>
      <category>coding</category>
    </item>
    <item>
      <title>Give Your Flutter Apps a Performance Pump 💪 with Deferred Imports</title>
      <dc:creator>Sudhanshu Kumar Yadav</dc:creator>
      <pubDate>Fri, 05 May 2023 08:01:00 +0000</pubDate>
      <link>https://forem.com/sky1095/give-your-flutter-apps-a-performance-pump-with-deferred-imports-1a99</link>
      <guid>https://forem.com/sky1095/give-your-flutter-apps-a-performance-pump-with-deferred-imports-1a99</guid>
      <description>&lt;p&gt;Hello, fellow Flutter/Dart enthusiasts! If you're looking to give your apps a performance boost, then you're in for a treat! Today, we're going to explore the magic of &lt;strong&gt;deferred imports&lt;/strong&gt; in Dart. By the end of this post, you'll learn how to lazy-load libraries, which can significantly improve the initial startup time of your apps.&lt;/p&gt;

&lt;p&gt;So buckle up and let's dive right in!&lt;/p&gt;

&lt;h3&gt;
  
  
  The Power of Deferred Imports
&lt;/h3&gt;

&lt;p&gt;Imagine you're working on a fantastic Dart application that requires a heavy library (like an image processing library). Now, loading this library can slow down your app's startup time, and we don't want that, right? That's where deferred imports come to our rescue!&lt;/p&gt;

&lt;p&gt;In Dart, the &lt;code&gt;deferred&lt;/code&gt; keyword allows you to lazy-load a library, meaning it's only loaded when it's actually needed. Combine this with the &lt;code&gt;as&lt;/code&gt; keyword to create an alias for the imported library, and you're all set! Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:heavy_library/heavy_library.dart'&lt;/span&gt; &lt;span class="kn"&gt;deferred&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;heavyLibrary&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  A Step-by-Step Guide to Deferred Imports
&lt;/h3&gt;

&lt;p&gt;Once you've declared the import using the &lt;code&gt;deferred&lt;/code&gt; keyword, you'll need to load the library explicitly before using its members. You do this by calling the &lt;code&gt;loadLibrary()&lt;/code&gt; function on the alias. Let's walk through a complete example:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;First, let's import our required libraries. We'll import &lt;code&gt;dart:async&lt;/code&gt; for working with &lt;code&gt;Future&lt;/code&gt;, and our heavy library using the &lt;code&gt;deferred&lt;/code&gt; keyword:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'dart:async'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:heavy_library/heavy_library.dart'&lt;/span&gt; &lt;span class="kn"&gt;deferred&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;heavyLibrary&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Now, create a &lt;code&gt;main&lt;/code&gt; function that will act as the entry point for our application:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;Future&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kd"&gt;async&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Application started.'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Perform some operations before loading the heavy library.&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;Future&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;delayed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Duration&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;seconds:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

  &lt;span class="c1"&gt;// Load the heavy library.&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;heavyLibrary&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;loadLibrary&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Heavy library loaded.'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Use the heavy library.&lt;/span&gt;
  &lt;span class="n"&gt;heavyLibrary&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;heavyFunction&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Heavy function executed.'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the &lt;code&gt;heavy_library&lt;/code&gt; package is imported using the &lt;code&gt;deferred&lt;/code&gt; keyword and aliased as &lt;code&gt;heavyLibrary&lt;/code&gt;. The main function of the application performs some operations before loading the heavy library using &lt;code&gt;await heavyLibrary.loadLibrary()&lt;/code&gt;. Once the library is loaded, you can call its members, like &lt;code&gt;heavyLibrary.heavyFunction()&lt;/code&gt; in this example.&lt;/p&gt;

&lt;p&gt;And that's it! You've just mastered the art of deferred imports in Dart!&lt;/p&gt;

&lt;h3&gt;
  
  
  Wrapping Up
&lt;/h3&gt;

&lt;p&gt;Now that you know how to use deferred imports in Dart, you can boost the performance of your apps by only loading heavy libraries when they're truly needed. This can be a game-changer, especially for large applications with numerous dependencies.&lt;/p&gt;

&lt;p&gt;So go on, give your Dart apps a performance boost, and keep coding! 🚀&lt;/p&gt;

&lt;p&gt;Credit for this post: &lt;a href="https://www.linkedin.com/posts/reham-ali-768895229_hello-flutter-developers-did-you-hear-activity-7057755093311369216-WIrP?utm_source=share&amp;amp;utm_medium=member_desktop"&gt;Reham Ali's LinkedIn Post 🤌&lt;/a&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>programming</category>
      <category>mobile</category>
    </item>
    <item>
      <title>Flutter + Firebase Messaging: A Match Made in App Heaven for Newbie Developers!</title>
      <dc:creator>Sudhanshu Kumar Yadav</dc:creator>
      <pubDate>Fri, 05 May 2023 07:33:24 +0000</pubDate>
      <link>https://forem.com/sky1095/flutter-firebase-messaging-a-match-made-in-app-heaven-for-newbie-developers-1kl5</link>
      <guid>https://forem.com/sky1095/flutter-firebase-messaging-a-match-made-in-app-heaven-for-newbie-developers-1kl5</guid>
      <description>&lt;p&gt;Welcome, dear novice app developer! If you're looking to add some pizzazz to your Flutter app with real-time notifications, you're in the right place! We'll show you how to set up Firebase Messaging in your Flutter app with ease. So, buckle up and let's get this party started! 🎉&lt;/p&gt;

&lt;h3&gt;
  
  
  What's Firebase Messaging, you ask?
&lt;/h3&gt;

&lt;p&gt;Firebase Cloud Messaging (FCM) is a free messaging service provided by Google that allows you to send notifications and data messages to your users' devices. It's the perfect solution for adding real-time communication to your app without breaking a sweat! 💪&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Set Up Firebase in Your Flutter Project
&lt;/h3&gt;

&lt;p&gt;Before diving into code, you'll need to create a Firebase project and connect it with your Flutter app. Follow the &lt;a href="https://firebase.flutter.dev/docs/overview"&gt;official FlutterFire documentation&lt;/a&gt; for step-by-step instructions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Add Firebase Messaging Dependency
&lt;/h3&gt;

&lt;p&gt;Add the &lt;code&gt;firebase_messaging&lt;/code&gt; package to your &lt;code&gt;pubspec.yaml&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;dependencies&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;flutter&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;sdk&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;flutter&lt;/span&gt;
  &lt;span class="na"&gt;firebase_messaging&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;^11.0.0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, run &lt;code&gt;flutter pub get&lt;/code&gt; to install the package.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Configure Firebase Messaging
&lt;/h3&gt;

&lt;p&gt;In your &lt;code&gt;main.dart&lt;/code&gt;, import the required packages and initialize Firebase:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:firebase_core/firebase_core.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:firebase_messaging/firebase_messaging.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kd"&gt;async&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;WidgetsFlutterBinding&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ensureInitialized&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;Firebase&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;initializeApp&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="n"&gt;runApp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Request Permission for Notifications
&lt;/h3&gt;

&lt;p&gt;Add the following code snippet inside your &lt;code&gt;MyApp&lt;/code&gt; widget's &lt;code&gt;build&lt;/code&gt; method to request notification permission:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;FirebaseMessaging&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;instance&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;requestPermission&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;alert:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;badge:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;sound:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5: Register Device Token
&lt;/h3&gt;

&lt;p&gt;You'll need a unique device token to send notifications to a specific device. To obtain it, add the following code snippet in your &lt;code&gt;main&lt;/code&gt; function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kd"&gt;async&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ... existing code&lt;/span&gt;
  &lt;span class="n"&gt;FirebaseMessaging&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;onBackgroundMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_backgroundMessageHandler&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;FirebaseMessaging&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;instance&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getToken&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Device Token: &lt;/span&gt;&lt;span class="si"&gt;$token&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="n"&gt;runApp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;Future&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;_backgroundMessageHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;RemoteMessage&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;async&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'A background message arrived: &lt;/span&gt;&lt;span class="si"&gt;${message.messageId}&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the printed token. You'll use it to send notifications via FCM.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6: Handle Incoming Notifications
&lt;/h3&gt;

&lt;p&gt;Let's handle notifications when the app is in the foreground:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;FirebaseMessaging&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;onMessage&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;RemoteMessage&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'A foreground message arrived: &lt;/span&gt;&lt;span class="si"&gt;${message.messageId}&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="c1"&gt;// You can add custom logic here, like displaying a snackbar or dialog.&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Voilà! 🎉 Your app is now set up to receive notifications from FCM!&lt;/p&gt;

&lt;h3&gt;
  
  
  Sending Test Notifications
&lt;/h3&gt;

&lt;p&gt;To test your shiny new notification system, use the following cURL command, replacing &lt;code&gt;&amp;lt;YOUR-FCM-SERVER-KEY&amp;gt;&lt;/code&gt; with your FCM server key and &lt;code&gt;&amp;lt;YOUR-DEVICE-TOKEN&amp;gt;&lt;/code&gt; with the printed device token:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -X POST \
  https://fcm.googleapis.com/fcm/send \
  -H 'Authorization: key=&amp;lt;YOUR-FCM-SERVER-KEY&amp;gt;' \
  -H 'Content-Type: application/json' \
  -d '{
        "to": "&amp;lt;YOUR-DEVICE-TOKEN&amp;gt;",
        "notification": {
          "title": "Test Notification",
          "body": "This is a test notification from FCM"
        }
     }'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>flutter</category>
      <category>dart</category>
      <category>firebase</category>
      <category>messaging</category>
    </item>
    <item>
      <title>Code like a child 👶🏻, build like a pro🧑🏻‍🔧: Unleash the magic of SOLID!</title>
      <dc:creator>Sudhanshu Kumar Yadav</dc:creator>
      <pubDate>Thu, 04 May 2023 18:35:20 +0000</pubDate>
      <link>https://forem.com/sky1095/code-like-a-child-build-like-a-pro-unleash-the-magic-of-solid-496a</link>
      <guid>https://forem.com/sky1095/code-like-a-child-build-like-a-pro-unleash-the-magic-of-solid-496a</guid>
      <description>&lt;p&gt;🚀🌟 Hey there 👋🏻, dev-nuggets and future coding prodigies! &lt;/p&gt;

&lt;p&gt;Today, I want to talk about the magical world of SOLID principles! Imagine if our code was like a LEGO castle where each piece is designed to fit perfectly with the others. That's what SOLID helps us achieve! 🏰✨&lt;/p&gt;

&lt;p&gt;🎨 Picture this: You're 5 years old, and you've just built the most amazing castle using your favourite LEGO bricks. Now, imagine that each of those LEGO bricks is a piece of code in your app. SOLID principles are like the magic instructions that help us build apps with LEGO bricks that click together perfectly every time! 🧙‍♂️🧩&lt;/p&gt;

&lt;p&gt;🌈 Here's a quick, colourful guide to SOLID for our little coding wizards:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;🦸‍♂️ &lt;strong&gt;S&lt;/strong&gt;ingle Responsibility Principle (SRP): Each LEGO brick (code piece) has a unique job, just like superheroes! We don't want Captain America to cook pizza when he's saving the world, right? 🍕🌍&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🎁 &lt;strong&gt;O&lt;/strong&gt;pen/Closed Principle (OCP): Think of your code like a surprise gift for someone. You can wrap it in new, exciting paper (extend), but you shouldn't have to open it up and mess with the toy inside (modify) to make it more fun! 🧸🎉&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🦉 &lt;strong&gt;L&lt;/strong&gt;iskov Substitution Principle (LSP): When you play with LEGOs, you can swap out a red brick for a blue one, and it still fits! That's what LSP is all about—making sure our code pieces can be swapped without breaking our castle! 🟥🔵&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🤝 &lt;strong&gt;I&lt;/strong&gt;nterface Segregation Principle (ISP): Imagine having a LEGO instruction book for each part of your castle. It's way easier to follow smaller, focused guides than one big, confusing manual. ISP helps us break down our code into simpler interfaces! 📚🏰&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🧪 &lt;strong&gt;D&lt;/strong&gt;ependency Inversion Principle (DIP): When building our LEGO castle, we want to rely on the shape of the bricks, not their colour. DIP reminds us to depend on abstractions (shape) rather than specifics (colour), making our code more flexible! 🌈🧱&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;🚀 So, my fellow coding enthusiasts, let's build our code castles with SOLID principles, and create apps that are as magical and fun as our favourite LEGO sets! And remember, even if you're not 5 years old, it's never too late to learn something new! 🎓✨&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>beginners</category>
      <category>programming</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
