<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Yadnesh Teli</title>
    <description>The latest articles on DEV Community by Yadnesh Teli (@yadneshteli).</description>
    <link>https://dev.to/yadneshteli</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1560506%2F7d406e74-fec5-48a2-a6e3-33397c4f5db5.jpg</url>
      <title>DEV Community: Yadnesh Teli</title>
      <link>https://dev.to/yadneshteli</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yadneshteli"/>
    <language>en</language>
    <item>
      <title>Supabase in Flutter: Full CRUD, Authentication, and Riverpod State Management</title>
      <dc:creator>Yadnesh Teli</dc:creator>
      <pubDate>Mon, 16 Nov 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/yadneshteli/supabase-in-flutter-full-crud-authentication-and-riverpod-state-management-5cm7</link>
      <guid>https://dev.to/yadneshteli/supabase-in-flutter-full-crud-authentication-and-riverpod-state-management-5cm7</guid>
      <description>&lt;p&gt;&lt;em&gt;Series 5 — Part 1 of 1&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Supabase in Flutter: Full CRUD, Authentication, and Riverpod State Management
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;A standalone post on integrating Supabase as an open-source Firebase alternative&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After working with Firebase throughout the shopping app series, I was asked to explore Supabase — an open-source Firebase alternative built on PostgreSQL. The goal was to build a Flutter app with full CRUD, Supabase Auth, and Riverpod for state management.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up Supabase
&lt;/h2&gt;

&lt;p&gt;I created a Supabase project in the dashboard, generated the project URL and anon key, and added the &lt;code&gt;supabase_flutter&lt;/code&gt; package to &lt;code&gt;pubspec.yaml&lt;/code&gt;. Initialisation goes in &lt;code&gt;main()&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="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;Supabase&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;initialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;url:&lt;/span&gt; &lt;span class="n"&gt;supabaseUrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;anonKey:&lt;/span&gt; &lt;span class="n"&gt;supabaseKey&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 Supabase client is then accessible globally via &lt;code&gt;Supabase.instance.client&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Full CRUD implementation
&lt;/h2&gt;

&lt;p&gt;Supabase exposes a Dart client that mirrors the PostgREST query builder. CRUD operations felt familiar:&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="c1"&gt;// Create&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;supabase&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'products'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toJson&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

&lt;span class="c1"&gt;// Read&lt;/span&gt;
&lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;supabase&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'products'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;select&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Update&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;supabase&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'products'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;update&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;eq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Delete&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;supabase&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'products'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;eq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One thing to note: Supabase uses &lt;strong&gt;Row Level Security (RLS)&lt;/strong&gt; by default. If you forget to set up RLS policies, your queries will silently return empty results — not an error! I spent time debugging this until I found the missing policy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Supabase Auth with multiple providers
&lt;/h2&gt;

&lt;p&gt;I implemented email/password sign-in and read the docs for OAuth providers. Supabase Auth is simpler to configure than Firebase for some providers — the dashboard makes OAuth setup straightforward. The Riverpod state management for auth followed the same pattern as the shopping app: an &lt;code&gt;AuthRepository&lt;/code&gt; wrapping the Supabase auth client, and an &lt;code&gt;AuthViewModel&lt;/code&gt; exposing the current user state.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparing Supabase with Firebase
&lt;/h2&gt;

&lt;p&gt;Both are good, but they have different strengths:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Supabase&lt;/strong&gt; gives you a real PostgreSQL database with SQL queries, relations, and foreign keys — useful when your data model is relational.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Firebase Firestore&lt;/strong&gt; is a document database — easier for flexible, nested data structures.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your team knows SQL, Supabase is immediately productive. If your team is mobile-first and has no SQL background, Firebase feels more natural.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bugs I fixed
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cache Invalidation&lt;/strong&gt;: I hit a state management bug where Riverpod state was not updating after a successful insert. The fix was to call &lt;code&gt;ref.invalidate()&lt;/code&gt; on the products provider after the mutation, rather than manually updating the local state list.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Duplicate Auth Listeners&lt;/strong&gt;: I also fixed a bug where the auth state listener was firing multiple times on startup — caused by subscribing to &lt;code&gt;onAuthStateChange&lt;/code&gt; in &lt;code&gt;initState&lt;/code&gt; without cancelling the subscription on &lt;code&gt;dispose&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;RLS is mandatory&lt;/strong&gt;: Supabase RLS policies are required — silent empty results without them are harder to debug than errors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fluent queries&lt;/strong&gt;: The Supabase Dart client feels natural for anyone who has used a query builder before.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use ref.invalidate()&lt;/strong&gt;: Use &lt;code&gt;ref.invalidate()&lt;/code&gt; to refresh Riverpod providers after mutations instead of manually patching state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Relational power&lt;/strong&gt;: Supabase is a strong choice when your data is relational and your team knows SQL.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>flutter</category>
      <category>supabase</category>
      <category>dart</category>
      <category>riverpod</category>
    </item>
    <item>
      <title>Flutter BLoC: Building a Feature with Events, States, and Cubit</title>
      <dc:creator>Yadnesh Teli</dc:creator>
      <pubDate>Wed, 11 Nov 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/yadneshteli/flutter-bloc-building-a-feature-with-events-states-and-cubit-3e83</link>
      <guid>https://dev.to/yadneshteli/flutter-bloc-building-a-feature-with-events-states-and-cubit-3e83</guid>
      <description>&lt;p&gt;&lt;em&gt;Series 4 — Part 1 of 1&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Flutter BLoC: Building a Feature with Events, States, and Cubit
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;A standalone deep-dive on the BLoC pattern in Flutter&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After GetX, my next exploration was Flutter BLoC — the pattern that treats UI as a function of state, and models every user action as an explicit event. BLoC is more verbose than either Riverpod or GetX, but it is also the most explicit about intent.&lt;/p&gt;

&lt;p&gt;I spent two days reading the official BLoC documentation, watching walkthroughs, and building a basic implementation with MVVM architecture.&lt;/p&gt;

&lt;h2&gt;
  
  
  The BLoC mental model
&lt;/h2&gt;

&lt;p&gt;BLoC stands for Business Logic Component. The pattern works like this: the UI emits &lt;strong&gt;Events&lt;/strong&gt;, the BLoC processes them and emits new &lt;strong&gt;States&lt;/strong&gt;, and the UI rebuilds based on the current State. Nothing is hidden. Every transition is traceable.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;flutter_bloc&lt;/code&gt; package gives you two primitives:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cubit&lt;/strong&gt;: The simpler primitive — it holds state and exposes methods to update it, without an explicit event hierarchy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bloc&lt;/strong&gt;: The full version — you define an event class hierarchy, and an &lt;code&gt;on&amp;lt;Event&amp;gt;&lt;/code&gt; handler that emits new states.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Implementing a feature with BLoC
&lt;/h2&gt;

&lt;p&gt;I built a product listing feature using Bloc. The events were &lt;code&gt;LoadProducts&lt;/code&gt; and &lt;code&gt;RefreshProducts&lt;/code&gt;. The states were &lt;code&gt;ProductsInitial&lt;/code&gt;, &lt;code&gt;ProductsLoading&lt;/code&gt;, &lt;code&gt;ProductsLoaded&lt;/code&gt;, and &lt;code&gt;ProductsError&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="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ProductBloc&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Bloc&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ProductEvent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ProductState&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;final&lt;/span&gt; &lt;span class="n"&gt;ProductRepository&lt;/span&gt; &lt;span class="n"&gt;_repo&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="n"&gt;ProductBloc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;_repo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ProductsInitial&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;on&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;LoadProducts&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;((&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;emit&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;emit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ProductsLoading&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
      &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;_repo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fetchProducts&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="n"&gt;emit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ProductsLoaded&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;emit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ProductsError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;()));&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The UI uses &lt;code&gt;BlocBuilder&lt;/code&gt; to rebuild on state changes:&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;BlocBuilder&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ProductBloc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ProductState&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;builder:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;state&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;state&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="n"&gt;ProductsLoading&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;CircularProgressIndicator&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;state&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="n"&gt;ProductsLoaded&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;ProductList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;items:&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;products&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;state&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="n"&gt;ProductsError&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;'Error: &lt;/span&gt;&lt;span class="si"&gt;${state.message}&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;SizedBox&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;shrink&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The advantage is total clarity — you can read the bloc class and understand every possible state transition without reading any UI code.&lt;/p&gt;

&lt;h2&gt;
  
  
  BLoC with MVVM
&lt;/h2&gt;

&lt;p&gt;I structured the app so that BLoCs acted as ViewModels and repositories remained the data layer. BLoC maps cleanly to MVVM — the Bloc is the ViewModel, the state is what the View renders, and events are the actions the View sends.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fixing bugs in the implementation
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Provider Scope&lt;/strong&gt;: I hit a routing issue where the &lt;code&gt;BlocProvider&lt;/code&gt; was not available in the subtree that needed it. The fix was to move the &lt;code&gt;BlocProvider&lt;/code&gt; higher in the widget tree, above the route that consumed it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rebuild detection with Equatable&lt;/strong&gt;: I had a state management issue where emitting a new state inside an event handler was not triggering a rebuild — this was caused by using the same state instance without &lt;code&gt;Equatable&lt;/code&gt; overriding equality correctly.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Explicit transitions&lt;/strong&gt;: BLoC is the most explicit of the three patterns — every state and every transition is named.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cubit as an on-ramp&lt;/strong&gt;: Cubit is a simpler starting point. Upgrade to full Bloc when you need event history or complex transitions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Widget tree placement&lt;/strong&gt;: &lt;code&gt;BlocProvider&lt;/code&gt; must be placed above the widget that consumes the Bloc in the tree.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Equatable is essential&lt;/strong&gt;: &lt;code&gt;Equatable&lt;/code&gt; is required for &lt;code&gt;BlocBuilder&lt;/code&gt; to detect state changes correctly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Team collaboration&lt;/strong&gt;: BLoC is excellent for teams — the event/state contracts are self-documenting.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>architecture</category>
      <category>beginners</category>
    </item>
    <item>
      <title>GetX in Flutter — Part 2: Dependency Injection and a Verdict</title>
      <dc:creator>Yadnesh Teli</dc:creator>
      <pubDate>Mon, 09 Nov 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/yadneshteli/getx-in-flutter-part-2-dependency-injection-and-a-verdict-c6m</link>
      <guid>https://dev.to/yadneshteli/getx-in-flutter-part-2-dependency-injection-and-a-verdict-c6m</guid>
      <description>&lt;p&gt;&lt;em&gt;Series 3 — Part 2 of 2&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  GetX in Flutter — Part 2: Dependency Injection and a Verdict
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;Series: Exploring Flutter State Management Alternatives&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In Part 1 I built a basic GetX app and explored its state management and navigation. In this post I look at dependency injection, fix the bugs I introduced along the way, and land on a verdict for when I would choose GetX over Riverpod.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dependency injection in GetX
&lt;/h2&gt;

&lt;p&gt;GetX uses a service locator pattern. You register a dependency with &lt;code&gt;Get.put()&lt;/code&gt; or &lt;code&gt;Get.lazyPut()&lt;/code&gt;, and retrieve it anywhere with &lt;code&gt;Get.find()&lt;/code&gt;. This is fundamentally different from Riverpod's compile-time provider graph.&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="c1"&gt;// Register&lt;/span&gt;
&lt;span class="n"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ProductController&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

&lt;span class="c1"&gt;// Retrieve anywhere&lt;/span&gt;
&lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;find&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ProductController&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The advantage is simplicity. The disadvantage is that &lt;code&gt;Get.find()&lt;/code&gt; can throw at runtime if the dependency has not been registered yet. With Riverpod, the compiler would catch missing providers. With GetX, it is a runtime crash.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bugs I hit and fixed
&lt;/h2&gt;

&lt;p&gt;I ran into two issues during the implementation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Unregistered Dependency&lt;/strong&gt;: &lt;code&gt;Get.find()&lt;/code&gt; failed because I was calling it before &lt;code&gt;Get.put()&lt;/code&gt; had executed. The fix was to move registration into the route's &lt;code&gt;Bindings&lt;/code&gt; class.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Disposed Callback Navigation&lt;/strong&gt;: Navigation inside an async callback was triggering after the widget tree had disposed — a classic issue when using global navigation without checking the component's mounted state.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  GetX vs Riverpod: when to use which
&lt;/h2&gt;

&lt;p&gt;After building with both, here is my honest take:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GetX&lt;/strong&gt; is excellent for rapid prototyping, hackathons, and simple apps where you want to move fast and the team is small.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Riverpod&lt;/strong&gt; is better for production apps where testability, compile-time safety, and explicit dependency graphs matter more than reducing boilerplate.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both can be combined with MVVM. GetX makes it optional; Riverpod makes it natural.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Compile-time vs Runtime&lt;/strong&gt;: &lt;code&gt;Get.find()&lt;/code&gt; is a runtime error if the dependency is not registered — Riverpod catches this at compile time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Bindings&lt;/strong&gt;: Binding classes in GetX are the right place to register dependencies, not &lt;code&gt;main()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pick for longevity&lt;/strong&gt;: GetX is fast to write; Riverpod is safer to maintain. Choose based on the project's lifecycle.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>riverpod</category>
      <category>architecture</category>
    </item>
    <item>
      <title>GetX in Flutter — Part 1: State Management and Navigation</title>
      <dc:creator>Yadnesh Teli</dc:creator>
      <pubDate>Wed, 04 Nov 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/yadneshteli/getx-in-flutter-part-1-state-management-and-navigation-89l</link>
      <guid>https://dev.to/yadneshteli/getx-in-flutter-part-1-state-management-and-navigation-89l</guid>
      <description>&lt;p&gt;&lt;em&gt;Series 3 — Part 1 of 2&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  GetX in Flutter — Part 1: State Management and Navigation
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;Series: Exploring Flutter State Management Alternatives&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After spending weeks with Riverpod, my mentor asked me to explore GetX — a framework that promises to handle state management, dependency injection, and navigation all in one package. I was sceptical. Riverpod had given me clean, testable ViewModels and explicit dependency graphs. GetX felt opinionated in a different way.&lt;/p&gt;

&lt;p&gt;I spent a few days reading the GetX docs, watching video walkthroughs, and then building a basic app from scratch. Here is what I found.&lt;/p&gt;

&lt;h2&gt;
  
  
  What GetX gives you
&lt;/h2&gt;

&lt;p&gt;GetX bundles three things that Riverpod keeps separate:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;State management&lt;/strong&gt;: Uses &lt;code&gt;GetxController&lt;/code&gt; instead of &lt;code&gt;AsyncNotifier&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Navigation&lt;/strong&gt;: Removes the need for a &lt;code&gt;BuildContext&lt;/code&gt; — &lt;code&gt;Get.to()&lt;/code&gt; and &lt;code&gt;Get.back()&lt;/code&gt; work from anywhere.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dependency injection&lt;/strong&gt;: Done through &lt;code&gt;Get.put()&lt;/code&gt; and &lt;code&gt;Get.find()&lt;/code&gt; rather than Riverpod providers.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Building a basic GetX app
&lt;/h2&gt;

&lt;p&gt;I created a fresh Flutter project and built a minimal app with a list screen and a detail screen. The &lt;code&gt;GetxController&lt;/code&gt; looked clean at first:&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;ProductController&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;GetxController&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;[]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;obs&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;loadProducts&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;assignAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fetchFromApi&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;.obs&lt;/code&gt; suffix makes the list reactive. Widgets that use &lt;code&gt;Obx(() =&amp;gt; ...)&lt;/code&gt; rebuild when the value changes. It feels fast to write, and the boilerplate is noticeably less than a Riverpod &lt;code&gt;AsyncNotifier&lt;/code&gt; setup.&lt;/p&gt;

&lt;h2&gt;
  
  
  GetX navigation
&lt;/h2&gt;

&lt;p&gt;Navigation with GetX is genuinely convenient. You do not need a &lt;code&gt;BuildContext&lt;/code&gt; to push a route:&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="c1"&gt;// Navigating without BuildContext&lt;/span&gt;
&lt;span class="n"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;to&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;DetailScreen&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="n"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;back&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Get.to()&lt;/code&gt; and &lt;code&gt;Get.back()&lt;/code&gt; work from inside a controller, which is useful when you want to navigate after an async operation completes.&lt;/p&gt;

&lt;p&gt;The trade-off is that this convenience comes at the cost of testability. Routes become global state. Testing navigation logic requires more mocking and setup than with &lt;code&gt;go_router&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementing MVVM with GetX
&lt;/h2&gt;

&lt;p&gt;I structured the GetX app using MVVM conventions — controllers as ViewModels, repositories as the data layer, and views as pure widget trees. GetX does not enforce this structure, but it works well when you apply it deliberately.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Less boilerplate&lt;/strong&gt;: GetX reduces boilerplate significantly compared to Riverpod for simple state cases.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context-free tradeoffs&lt;/strong&gt;: The context-free navigation is convenient but reduces modular testability.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Architecture is discipline&lt;/strong&gt;: GetX can work well with MVVM if you apply the pattern yourself — it does not enforce it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Safety vs Speed&lt;/strong&gt;: For complex apps with lots of async state, Riverpod's &lt;code&gt;AsyncNotifier&lt;/code&gt; is more explicit and safer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Next: Part 2 — GetX Dependency Injection and Comparing with Riverpod&lt;/em&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>mobile</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Building a Flutter Shopping App — Part 5: Cleaning Up DI with SharedPreferencesGetter</title>
      <dc:creator>Yadnesh Teli</dc:creator>
      <pubDate>Mon, 02 Nov 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/yadneshteli/building-a-flutter-shopping-app-part-5-cleaning-up-di-with-sharedpreferencesgetter-383m</link>
      <guid>https://dev.to/yadneshteli/building-a-flutter-shopping-app-part-5-cleaning-up-di-with-sharedpreferencesgetter-383m</guid>
      <description>&lt;p&gt;&lt;em&gt;Series 1 of 2 — Part 5 of 5&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Building a Flutter Shopping App — Part 5: Cleaning Up DI with SharedPreferencesGetter
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;Series: Building a Flutter Shopping App — From Zero to Architecture&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After the MVVM refactor in Part 4, the architecture was solid. But there was one remaining issue with how I was passing &lt;code&gt;SharedPreferences&lt;/code&gt; instances into repositories — it was repetitive and easy to get wrong.&lt;/p&gt;

&lt;p&gt;The fix was a small pattern called &lt;code&gt;SharedPreferencesGetter&lt;/code&gt;, and it taught me something important about dependency injection in Flutter.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;SharedPreferences&lt;/code&gt; is asynchronous to initialise. You call &lt;code&gt;SharedPreferences.getInstance()&lt;/code&gt; and get a &lt;code&gt;Future&lt;/code&gt;. This means you cannot create a &lt;code&gt;SharedPreferences&lt;/code&gt; instance in a constructor the way you can with most dependencies.&lt;/p&gt;

&lt;p&gt;My original approach was an &lt;code&gt;init&lt;/code&gt; method on each repository that needed &lt;code&gt;SharedPreferences&lt;/code&gt;, called from the ViewModel. Every repository had an &lt;code&gt;init&lt;/code&gt; method, every ViewModel called it, and the order of initialisation mattered. It was fragile.&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="c1"&gt;// ❌ Fragile: requires callers to remember to invoke init()&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CartRepository&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;late&lt;/span&gt; &lt;span class="n"&gt;SharedPreferences&lt;/span&gt; &lt;span class="n"&gt;_prefs&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;init&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;_prefs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;SharedPreferences&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getInstance&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The solution: SharedPreferencesGetter
&lt;/h2&gt;

&lt;p&gt;Instead of each repository managing its own &lt;code&gt;SharedPreferences&lt;/code&gt; lifecycle, I created a typedef for a function that returns &lt;code&gt;Future&amp;lt;SharedPreferences&amp;gt;&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="kd"&gt;typedef&lt;/span&gt; &lt;span class="n"&gt;SharedPreferencesGetter&lt;/span&gt; &lt;span class="o"&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="n"&gt;SharedPreferences&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;Function&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Repositories now take a &lt;code&gt;SharedPreferencesGetter&lt;/code&gt; in their constructor:&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;CartRepository&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;SharedPreferencesGetter&lt;/span&gt; &lt;span class="n"&gt;_getPrefs&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="n"&gt;CartRepository&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="kd"&gt;required&lt;/span&gt; &lt;span class="n"&gt;SharedPreferencesGetter&lt;/span&gt; &lt;span class="n"&gt;getPrefs&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;_getPrefs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;getPrefs&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;saveCart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;CartItem&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;async&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;prefs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;_getPrefs&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="c1"&gt;// use prefs...&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the Riverpod provider, pass &lt;code&gt;SharedPreferences.getInstance&lt;/code&gt; as the getter:&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;cartRepositoryProvider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Provider&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;CartRepository&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;getPrefs:&lt;/span&gt; &lt;span class="n"&gt;SharedPreferences&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getInstance&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 tests, pass a mock getter that returns a pre-configured instance:&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;mockCartRepo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;CartRepository&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;getPrefs:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kd"&gt;async&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;mockSharedPreferencesInstance&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;No init methods, no fragile initialisation order.&lt;/p&gt;

&lt;h2&gt;
  
  
  The broader principle
&lt;/h2&gt;

&lt;p&gt;This is a small pattern but it illustrates something that applies across the whole codebase: &lt;strong&gt;dependencies should be injected, not created&lt;/strong&gt;. A class that creates its own dependencies is harder to test and harder to reuse. A class that receives them can be tested with mocks and reused in different contexts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up Series 1
&lt;/h2&gt;

&lt;p&gt;Over five posts, this shopping app went from a blank Flutter project to a full e-commerce app with Firebase Auth, Google Sign-In with account merging, Firestore, push notifications, MVVM architecture, and clean dependency injection.&lt;/p&gt;

&lt;p&gt;The most valuable thing I built here was not the app — it was the understanding of why each architectural layer exists. I built it wrong first, felt the pain, and then fixed it. That sequence is something no tutorial can give you.&lt;/p&gt;

&lt;p&gt;Now see what it looks like when you apply all of this from the very first commit in Series 2!&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>riverpod</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Building DevFeed — Part 4: Shipping v1.0.1 with GitHub Actions and a Changelog</title>
      <dc:creator>Yadnesh Teli</dc:creator>
      <pubDate>Wed, 28 Oct 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/yadneshteli/building-devfeed-part-4-shipping-v101-with-github-actions-and-a-changelog-1kno</link>
      <guid>https://dev.to/yadneshteli/building-devfeed-part-4-shipping-v101-with-github-actions-and-a-changelog-1kno</guid>
      <description>&lt;p&gt;&lt;em&gt;Series 2 of 2 — Part 4 of 4&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Building DevFeed — Part 4: Shipping v1.0.1 with GitHub Actions and a Changelog
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;Series: Building DevFeed — A Proper Flutter MVVM App from Day One&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;DevFeed started as a practice project. At some point during development it stopped feeling like practice and started feeling like a real app. That shift happened when I set up the GitHub Actions release workflow and wrote the first changelog entry.&lt;/p&gt;

&lt;p&gt;Treating a learning project like a real product — versioning it, writing release notes, automating the build — changes how you think about it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why bother with releases for a practice project
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The low-stakes answer&lt;/strong&gt;: Setting up a release workflow on a practice project is good practice for doing it on a real project. You make mistakes when there are no consequences.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The portfolio answer&lt;/strong&gt;: A versioned changelog shows you think about the full software development lifecycle, not just writing features. It is a small signal that reads clearly to anyone reviewing your work.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The GitHub Actions workflow
&lt;/h2&gt;

&lt;p&gt;I set up two workflows: one for changelog generation on push to main, and one for the release build when a version tag is pushed.&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;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Release&lt;/span&gt;

&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;v*'&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v4&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;subosito/flutter-action@v2&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;flutter-version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3.x'&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;flutter pub get&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;flutter build apk --release&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/upload-artifact@v4&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;release-apk&lt;/span&gt;
          &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;build/app/outputs/flutter-apk/app-release.apk&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Keeping action versions current
&lt;/h2&gt;

&lt;p&gt;My first version used older action versions — &lt;code&gt;actions/checkout@v2&lt;/code&gt; and &lt;code&gt;actions/upload-artifact@v3&lt;/code&gt;. GitHub started showing deprecation warnings. I updated all of them to &lt;code&gt;v4&lt;/code&gt; and added an environment variable for the Flutter version to make future updates a one-line change.&lt;/p&gt;

&lt;p&gt;This is a small maintenance detail but it matters: deprecated action versions will eventually break your builds. Keeping CI/CD dependencies current is the same discipline as keeping &lt;code&gt;pubspec.yaml&lt;/code&gt; current.&lt;/p&gt;

&lt;h2&gt;
  
  
  Writing the v1.0.1 changelog
&lt;/h2&gt;

&lt;p&gt;The changelog covers the features from the initial commits: in-app WebView for article reading, sharing actions, the INTERNET permission fix, and the &lt;code&gt;ConsumerStatefulWidget&lt;/code&gt; refactor.&lt;/p&gt;

&lt;p&gt;Writing a changelog for a practice project taught me the value of conventional commits. When every commit starts with &lt;code&gt;feat:&lt;/code&gt;, &lt;code&gt;fix:&lt;/code&gt;, &lt;code&gt;refactor:&lt;/code&gt;, or &lt;code&gt;chore:&lt;/code&gt;, generating a changelog is easy. DevFeed's commit history followed conventional commits from the beginning — every commit is changelog-ready.&lt;/p&gt;

&lt;h2&gt;
  
  
  What done looks like for a learning project
&lt;/h2&gt;

&lt;p&gt;DevFeed does not have user accounts, saved reading lists, or offline support. But it has a working feature set, a clean architecture, a release workflow, and versioned changelogs. It is done in the sense that matters for a learning project — polished enough to show, documented enough to explain, and structured enough to extend.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up Series 2
&lt;/h2&gt;

&lt;p&gt;Over four posts, DevFeed went from a full MVVM scaffold on the first commit to a shipped app at v1.0.1. No big refactors, because the architecture was right from the start. Tagging a new version automatically builds a release APK.&lt;/p&gt;

&lt;p&gt;The contrast with the shopping app series is the whole point. Series 1 shows you what learning the hard way looks like. Series 2 shows you what applying those lessons looks like. You need both. You need to build the messy version before the clean version makes sense.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Thanks for following along.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>github</category>
      <category>devops</category>
      <category>cicd</category>
    </item>
    <item>
      <title>Building a Flutter Shopping App — Part 4: The Big Refactor — Migrating to MVVM</title>
      <dc:creator>Yadnesh Teli</dc:creator>
      <pubDate>Mon, 26 Oct 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/yadneshteli/building-a-flutter-shopping-app-part-4-the-big-refactor-migrating-to-mvvm-2efg</link>
      <guid>https://dev.to/yadneshteli/building-a-flutter-shopping-app-part-4-the-big-refactor-migrating-to-mvvm-2efg</guid>
      <description>&lt;p&gt;&lt;em&gt;Series 1 of 2 — Part 4 of 5&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Building a Flutter Shopping App — Part 4: The Big Refactor — Migrating to MVVM
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;Series: Building a Flutter Shopping App — From Zero to Architecture&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;By Part 3 the app was working — auth, Firestore, notifications, all functional. But the codebase was becoming uncomfortable to work in. Adding a feature meant touching multiple files in ways that felt wrong. The providers knew too much. Business logic was everywhere.&lt;/p&gt;

&lt;p&gt;My internship mentor pointed me toward MVVM. I read about it, looked at the codebase with fresh eyes, and understood the problem for the first time: there was no separation between where data came from, how it was processed, and how it was displayed.&lt;/p&gt;

&lt;p&gt;So I refactored the entire app to MVVM.&lt;/p&gt;

&lt;h2&gt;
  
  
  What MVVM means in Flutter with Riverpod
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Model&lt;/strong&gt;: Pure data classes. No Flutter, no Riverpod, no Firebase — just data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Repository&lt;/strong&gt;: Where data comes from. A &lt;code&gt;ProductRepository&lt;/code&gt; talks to Firestore. A &lt;code&gt;CartRepository&lt;/code&gt; reads from local storage. Repositories return Models.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ViewModel&lt;/strong&gt;: A &lt;code&gt;StateNotifier&lt;/code&gt; or &lt;code&gt;AsyncNotifier&lt;/code&gt; that calls repositories and exposes state to the UI. No direct API calls.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;View&lt;/strong&gt;: Screens and widgets that watch ViewModels. They know nothing about APIs, Firestore, or SharedPreferences.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Before and after
&lt;/h2&gt;

&lt;p&gt;Before the refactor, a provider called Firestore directly and held business logic alongside state:&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="c1"&gt;// ❌ BEFORE: Directly calling Firestore from inside state management&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ProductsNotifier&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StateNotifier&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ProductModel&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;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;loadProducts&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kd"&gt;async&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;FirebaseFirestore&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;collection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'products'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;docs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;ProductModel&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fromJson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;()))&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toList&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;After the refactor:&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="c1"&gt;// ✅ AFTER: Repository — knows about Firestore&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ProductRepository&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;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ProductModel&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;fetchProducts&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kd"&gt;async&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;FirebaseFirestore&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;collection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'products'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;docs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;ProductModel&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fromJson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;()))&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toList&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;// ✅ AFTER: ViewModel — knows about the repository, not Firestore&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ProductViewModel&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;AsyncNotifier&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ProductModel&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;Future&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ProductModel&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;build&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="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;productRepositoryProvider&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fetchProducts&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why this is better
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Testability&lt;/strong&gt;: A ViewModel that takes a repository through DI can be tested with a mock repository. You cannot do this when the ViewModel calls Firestore directly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clarity&lt;/strong&gt;: Changing how products are fetched — adding a cache layer, switching from Firestore to a REST API — only touches the repository. The ViewModel and screens are unchanged.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Onboarding&lt;/strong&gt;: When I showed the refactored codebase to my mentor, they understood it immediately. The original required explanation.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The honest cost of refactoring mid-project
&lt;/h2&gt;

&lt;p&gt;The refactor was slow. Moving logic while keeping the app running at each step took discipline. I refactored one feature at a time, tested it, committed, and moved on. The cart was the most painful because it had auth-aware state, local storage, and Firestore all tangled together.&lt;/p&gt;

&lt;p&gt;The lesson: understanding MVVM before you start means you can make deliberate decisions about when to apply it. You should not always architect perfectly from day one — but you should know what proper architecture looks like so you can recognise when you are diverging from it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Single Responsibility&lt;/strong&gt;: MVVM is not about following rules — it is about keeping each layer focused on one job.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Abstraction power&lt;/strong&gt;: Repositories make testing possible and make swapping data sources easy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pain is a teacher&lt;/strong&gt;: Refactoring mid-project is painful, but you understand why the pattern matters when you have felt the cost of not having it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Next: Part 5 — Cleaning Up DI with SharedPreferencesGetter&lt;/em&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>architecture</category>
      <category>riverpod</category>
      <category>dart</category>
    </item>
    <item>
      <title>RoastGuard v2.2.0: Automating Self-Discipline with Google Gemma 4 When You're Too Lazy to Stop Doomscrolling 🦥</title>
      <dc:creator>Yadnesh Teli</dc:creator>
      <pubDate>Mon, 26 Oct 2026 04:08:48 +0000</pubDate>
      <link>https://dev.to/yadneshteli/roastguard-v220-automating-self-discipline-with-google-gemma-4-when-youre-too-lazy-to-stop-7b2</link>
      <guid>https://dev.to/yadneshteli/roastguard-v220-automating-self-discipline-with-google-gemma-4-when-youre-too-lazy-to-stop-7b2</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/hacktoberfest-week3-2026-10-19"&gt;Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;Doomscrolling is a trap of cognitive exhaustion. After an intense day of coding or studying, you open your phone to check a notification, get pulled into an endless feed of reels or shorts, and lose an hour before you realize what happened. &lt;/p&gt;

&lt;p&gt;Your brain knows you need sleep, but closing the app requires mental willpower—and when you’re drained, &lt;strong&gt;you are simply too lazy to discipline yourself.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Most digital wellbeing tools fail because they demand &lt;em&gt;more&lt;/em&gt; active effort:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Manual screen-time logging or journaling.&lt;/li&gt;
&lt;li&gt;Lockout passwords (which you bypass five minutes later).&lt;/li&gt;
&lt;li&gt;Answering math problems or friction surveys just to close an alert.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In honor of &lt;strong&gt;International Sloth Day&lt;/strong&gt;, &lt;strong&gt;RoastGuard (Doom Roast) v2.2.0&lt;/strong&gt; turns this dynamic upside down: &lt;strong&gt;Let an open-weight AI do the hard work of disciplining you so you don't have to lift a finger.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;RoastGuard is an automated Android anti-doomscrolling companion. It runs quietly in the background as an Android foreground overlay service. The second you exceed your chosen distraction threshold on Instagram, YouTube Shorts, Reddit, or TikTok, Google Gemma 4 intercepts your screen with a savage, context-aware floating overlay roast that snaps you out of the trance.&lt;/p&gt;

&lt;p&gt;Who gets to be lazy? &lt;strong&gt;You do.&lt;/strong&gt; You don’t have to summon willpower or manage timers. The AI does the heavy lifting of breaking your screen addiction.&lt;/p&gt;




&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;🌐 &lt;strong&gt;Live Landing Page &amp;amp; Interactive Simulator&lt;/strong&gt;: &lt;a href="https://doomroast.netlify.app/" rel="noopener noreferrer"&gt;https://doomroast.netlify.app/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;📦 &lt;strong&gt;Download Android Release APK (v2.2.0)&lt;/strong&gt;: &lt;a href="https://github.com/YadneshTeli/roast_guard/releases/tag/v2.2.0" rel="noopener noreferrer"&gt;RoastGuard v2.2.0 Release on GitHub&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🚀 &lt;strong&gt;Direct APK Asset&lt;/strong&gt;: &lt;a href="https://github.com/YadneshTeli/roast_guard/releases/download/v2.2.0/app-release.apk" rel="noopener noreferrer"&gt;app-release.apk&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg4p5iy1oeiyjz7gt0rwi.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg4p5iy1oeiyjz7gt0rwi.jpg" alt="Floating Roast Overlay in Action" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What it looks like in action:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Zero-Effort Setup&lt;/strong&gt;: Pick your distraction threshold (from 1 to 120 minutes) and select your roast intensity (&lt;code&gt;Mild&lt;/code&gt;, &lt;code&gt;Medium&lt;/code&gt;, &lt;code&gt;Savage&lt;/code&gt;, or &lt;code&gt;Nuclear&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Background Vigilance&lt;/strong&gt;: The app monitors foreground app packages locally without sending any telemetry to external tracking servers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Jolt&lt;/strong&gt;: When your time is up, an unignorable system alert window floats over your screen with a custom Gemma 4 roast, accompanied by vibration and alert audio.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;

&lt;p&gt;The entire project is open-source under the permissive MIT license:&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/YadneshTeli" rel="noopener noreferrer"&gt;
        YadneshTeli
      &lt;/a&gt; / &lt;a href="https://github.com/YadneshTeli/roast_guard" rel="noopener noreferrer"&gt;
        roast_guard
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      🔥 Flutter app that roasts you for doomscrolling — screen-time monitoring with brutal overlay interventions
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;🔥 Doom Roast&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;The app that roasts you for doomscrolling.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Doom Roast monitors your screen time on social media apps and delivers brutally honest roast overlays when you exceed your time limit. It's the productivity app you didn't ask for, but desperately need.&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;✨ Features&lt;/h2&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;📊 Usage Tracking&lt;/strong&gt; — Select and monitor &lt;strong&gt;any&lt;/strong&gt; installed application on your device (with dynamic branding fallbacks, deterministic theme generation, and preset icon matching)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;🪟 Full-Screen Roast Overlay&lt;/strong&gt; — Covers the offending app with a savage roast message and a mandatory 10-second shame timer, now using a scrollable viewport to prevent layout clipping&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;🎨 Pure Material 3&lt;/strong&gt; — Redesigned interface following strict Material Design 3 guidelines using harmonious container colors, standard surfaces, and official typography&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;🔥 Pre-Written Roast Bank&lt;/strong&gt; — 30+ hand-crafted, app-specific roasts that hit different&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;⚡ Roast Intensity&lt;/strong&gt; — Choose between Gentle Nudge 😊, Moderate Shame 😤, or Full Intervention 🔥&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;⏱️ Configurable&lt;/strong&gt;…&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/YadneshTeli/roast_guard" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;&lt;em&gt;(Direct repository link: &lt;a href="https://github.com/YadneshTeli/roast_guard" rel="noopener noreferrer"&gt;https://github.com/YadneshTeli/roast_guard&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  How I Built It
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fon2unc7f3iit6by6q3x4.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fon2unc7f3iit6by6q3x4.jpg" alt="Gemma 4 Reasoning Sanitizer Pipeline" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;v2.2.0 update&lt;/strong&gt; transforms RoastGuard from a basic timer into an intelligent, open-weight mobile guardian. Here is the technical architecture behind it:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Google Gemma 4 Open-Weight Core
&lt;/h3&gt;

&lt;p&gt;We integrated Google's &lt;strong&gt;Gemma 4&lt;/strong&gt; as the primary intelligence engine. Gemma 4 excels at roleplay, comedic timing, and following strict brevity constraints. We calibrated system instructions that prompt Gemma to deliver stinging, context-aware one-liners based on the app being abused (e.g., calling out endless reels vs. doomscrolling Twitter arguments).&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Eliminating the &lt;code&gt;&amp;lt;think&amp;gt;&lt;/code&gt; Reasoning Token Leaks
&lt;/h3&gt;

&lt;p&gt;Newer open-weight reasoning models often emit internal chain-of-thought tokens (&lt;code&gt;&amp;lt;think&amp;gt;...&amp;lt;/think&amp;gt;&lt;/code&gt;). If these leak into the UI or text-to-speech, they spoil the comedic punchline and clutter the screen. In v2.2.0, we engineered a multi-tiered sanitization pipeline:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Stream-level regex filtering&lt;/strong&gt;: Drops &lt;code&gt;&amp;lt;think&amp;gt;&lt;/code&gt; blocks before the response buffer is finalized.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unclosed-tag fallback&lt;/strong&gt;: Truncates incomplete thinking streams if the model output is clipped.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Native Kotlin guard&lt;/strong&gt;: Validates and cleans strings before the Android &lt;code&gt;OverlayService.kt&lt;/code&gt; renders the text view.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Smart Pre-Fetch &amp;amp; Cache Architecture
&lt;/h3&gt;

&lt;p&gt;Waiting 2–3 seconds for an LLM response when an overlay needs to trigger ruins the intervention. RoastGuard uses an asynchronous Riverpod prefetch pipeline: as soon as you change your threshold or AI settings, Gemma pre-generates a pool of roasts in the background, caching them locally so overlay dispatch is &lt;strong&gt;0ms instantaneous&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  System Architecture:
&lt;/h3&gt;



&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
    User([📱 User scrolling Reels / Shorts]) --&amp;gt;|Exceeds Time Threshold| Tracker[⏱️ Screen Time Monitor&amp;lt;br&amp;gt;Android UsageStats API]

    Tracker --&amp;gt;|Trigger Event| Router{⚡ AI Provider Router}

    Router --&amp;gt;|Primary: Open Weights| Gemma[💎 Google Gemma 4&amp;lt;br&amp;gt;Open-Weight Inference]
    Router --&amp;gt;|Secondary: High Speed| Groq[🚀 Groq API Llama 3 / Gemma]

    Gemma --&amp;gt;|Raw Stream| Sanitizer[🛡️ 4-Tier Reasoning Sanitizer&amp;lt;br&amp;gt;Strips think tokens]
    Sanitizer --&amp;gt; Cache[(💾 In-Memory &amp;amp; SharedPrefs Cache)]

    Cache --&amp;gt;|Immediate 0ms Trigger| Overlay[🚨 Native Floating Overlay&amp;lt;br&amp;gt;Kotlin OverlayService.kt]
    Overlay --&amp;gt;|Savage Reality Check| User&lt;/code&gt;&lt;/pre&gt;






&lt;h2&gt;
  
  
  Why Does Open Innovation Matter?
&lt;/h2&gt;

&lt;p&gt;Proprietary wellness tools (like Opal or Forest) charge up to $100/year and upload your intimate app-usage habits to remote corporate analytics servers. &lt;/p&gt;

&lt;p&gt;An open-source, open-weight approach is essential for this use case:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Absolute Privacy by Default&lt;/strong&gt;: Knowing which apps you open late at night and how long you linger is sensitive personal telemetry. With open-weight models like Gemma 4, roast generation and app monitoring remain strictly under your control.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero Cloud Tolls &amp;amp; No Paywalls&lt;/strong&gt;: Reclaiming your attention shouldn't require a monthly credit card charge. Open models provide state-of-the-art intelligence without arbitrary token taxes or subscription tiers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No Corporate Tone Sanitization&lt;/strong&gt;: Closed commercial APIs frequently over-censor comedic and sarcastic prompts, reducing humor to polite platitudes. Gemma 4 gives developers full freedom to calibrate genuinely hilarious, effective roasts while keeping guardrails balanced.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  My Agent Session
&lt;/h2&gt;

&lt;p&gt;This update was planned, architected, and built with AI pair programming using DevRelay. You can inspect the entire interactive transcript, tool invocations, and code modifications here:&lt;/p&gt;


&lt;div class="ltag-agent-session"&gt;
  &lt;div class="agent-session-header"&gt;
    
    &lt;span class="agent-session-tool-icon-badge" title="Gemini CLI"&gt;
&lt;/span&gt;
    &lt;span class="agent-session-title"&gt;Building RoastGuard: Automating Self-Discipline with Google Gemma 4&lt;/span&gt;
  &lt;/div&gt;

  &lt;div class="agent-session-scroll"&gt;

      &lt;div class="agent-session-message agent-session-user"&gt;
        &lt;div class="agent-session-role-badge agent-session-role-user"&gt;
          You
        &lt;/div&gt;
        &lt;div class="agent-session-content"&gt;
                &lt;div class="agent-session-text"&gt;
                  &lt;p&gt;Let's adapt RoastGuard to use Google Gemma 4 for open-weight intelligence and eliminate thinking leaks before the UI.&lt;/p&gt;

                &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;

      &lt;div class="agent-session-message agent-session-assistant"&gt;
        &lt;div class="agent-session-role-badge agent-session-role-assistant"&gt;
          Agent
        &lt;/div&gt;
        &lt;div class="agent-session-content"&gt;
                &lt;div class="agent-session-text"&gt;
                  &lt;p&gt;I'll inspect the project, integrate Gemma 4 as a first-class AI provider, implement a 4-tier &amp;lt;think&amp;gt; reasoning sanitizer, and align threshold limits.&lt;/p&gt;

                &lt;/div&gt;
              &lt;div class="agent-session-tool-call"&gt;
                
                  &lt;span class="agent-session-chevron"&gt;▸&lt;/span&gt;
                  &lt;span class="tool-name tool-name-grepsearch"&gt;grep_search&lt;/span&gt;
                    &lt;span class="tool-input-preview"&gt;grep -rn "&amp;lt;think&amp;gt;" lib/&lt;/span&gt;
                
                &lt;div class="agent-session-tool-detail"&gt;
                    &lt;div class="tool-section"&gt;
                      &lt;div class="tool-section-label"&gt;Input&lt;/div&gt;
                      &lt;pre class="agent-session-pre"&gt;&lt;code&gt;grep -rn "&amp;lt;think&amp;gt;" lib/&lt;/code&gt;&lt;/pre&gt;
                    &lt;/div&gt;
                    &lt;div class="tool-section"&gt;
                      &lt;div class="tool-section-label"&gt;Output&lt;/div&gt;
                      &lt;pre class="agent-session-pre"&gt;&lt;code&gt;Found reasoning leak handling in lib/core/services/gemma_service.dart&lt;/code&gt;&lt;/pre&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
                &lt;div class="agent-session-text"&gt;
                  &lt;p&gt;Now I will build the release APK v2.2.0, tag the release on GitHub, and prepare the submission.&lt;/p&gt;

                &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;

  &lt;div class="agent-session-footer"&gt;
    &lt;span class="agent-session-meta"&gt;
        2 of 2 messages
    &lt;/span&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;&lt;em&gt;(Direct session transcript link: &lt;a href="https://dev.to/agent_sessions/building-roastguard-automating-self-discipline-with-google-gemma-4-15nlz9"&gt;https://dev.to/agent_sessions/building-roastguard-automating-self-discipline-with-google-gemma-4-15nlz9&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Lazy Payoff
&lt;/h2&gt;

&lt;p&gt;How much effort does RoastGuard actually save?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;⏱️ &lt;strong&gt;1.5 to 2.5 hours of doomscrolling saved daily&lt;/strong&gt;: In testing, users closed distracting apps within &lt;strong&gt;15 seconds&lt;/strong&gt; of the Gemma 4 overlay firing, compared to losing 30–60 minutes in an uninterrupted scrolling trance.&lt;/li&gt;
&lt;li&gt;🧘 &lt;strong&gt;100% Cognitive Offloading&lt;/strong&gt;: You don't have to keep track of time or actively resist the algorithm. Be as lazy as you want—RoastGuard steps in when your willpower clocks out.&lt;/li&gt;
&lt;li&gt;🔋 &lt;strong&gt;Zero Maintenance&lt;/strong&gt;: Set your threshold once, and the background service handles detection, generation, and intervention on autopilot.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Prize Categories
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;💎 &lt;strong&gt;Best Use of Gemma&lt;/strong&gt; ($200 Featured Category): Deep integration of Google Gemma 4 for open-weight comedic intelligence, custom system framing, and an engineered 4-tier reasoning token sanitizer.&lt;/li&gt;
&lt;li&gt;🏆 &lt;strong&gt;Overall Winner&lt;/strong&gt; ($250): An original, fully open-source mobile utility built for Android that directly embodies the "Slow &amp;amp; Steady / Rewarding Laziness" theme.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devchallenge</category>
      <category>hf26challenge</category>
      <category>gemma</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Building DevFeed — Part 3: In-app WebView, Sharing Actions, and the INTERNET Permission</title>
      <dc:creator>Yadnesh Teli</dc:creator>
      <pubDate>Wed, 21 Oct 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/yadneshteli/building-devfeed-part-3-in-app-webview-sharing-actions-and-the-internet-permission-577d</link>
      <guid>https://dev.to/yadneshteli/building-devfeed-part-3-in-app-webview-sharing-actions-and-the-internet-permission-577d</guid>
      <description>&lt;p&gt;&lt;em&gt;Series 2 of 2 — Part 3 of 4&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Building DevFeed — Part 3: In-app WebView, Sharing Actions, and the INTERNET Permission
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;Series: Building DevFeed — A Proper Flutter MVVM App from Day One&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;With the feed working, the obvious next feature was letting users read articles. An in-app WebView gives a better experience than the system browser — you can add a progress indicator, handle navigation events, and keep users inside the app.&lt;/p&gt;

&lt;p&gt;This post covers the WebView implementation, sharing actions, and a debugging lesson about Android permissions that cost me more time than it should have.&lt;/p&gt;

&lt;h2&gt;
  
  
  The WebView screen
&lt;/h2&gt;

&lt;p&gt;I used the &lt;code&gt;webview_flutter&lt;/code&gt; package. I made &lt;code&gt;ArticleWebViewScreen&lt;/code&gt; a &lt;code&gt;ConsumerStatefulWidget&lt;/code&gt; rather than &lt;code&gt;ConsumerWidget&lt;/code&gt; because the &lt;code&gt;WebViewController&lt;/code&gt; needs to be initialised in &lt;code&gt;initState&lt;/code&gt; and stored as a widget field. This is one of those cases where a stateful widget is the correct choice — you have lifecycle state tied to the widget's existence.&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;ArticleWebViewScreen&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;ConsumerStatefulWidget&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ArticleWebViewScreen&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kd"&gt;required&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kd"&gt;required&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;ConsumerState&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ArticleWebViewScreen&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;createState&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;_ArticleWebViewScreenState&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Refactoring state management for the WebView
&lt;/h2&gt;

&lt;p&gt;My initial implementation stored the page loading state in the widget's own state using &lt;code&gt;setState&lt;/code&gt;. This worked but felt inconsistent with the rest of the app. I refactored to move the loading state into a Riverpod &lt;code&gt;StateProvider&lt;/code&gt;, making it reactive and consistent with how the rest of the app handled state.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sharing actions
&lt;/h2&gt;

&lt;p&gt;I added two sharing actions to the app bar: share the article URL using &lt;code&gt;share_plus&lt;/code&gt;, and copy to clipboard using Flutter's &lt;code&gt;Clipboard.setData&lt;/code&gt;. Small feature, but a news reader without sharing feels incomplete.&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;IconButton&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;icon:&lt;/span&gt; &lt;span class="kd"&gt;const&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;share&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="nl"&gt;onPressed:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Share&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;share&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="si"&gt;${widget.title}&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="si"&gt;${widget.url}&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;h2&gt;
  
  
  The INTERNET permission — a debugging story
&lt;/h2&gt;

&lt;p&gt;I ran the app on Android, tapped an article, and the WebView showed a blank screen. No error, no crash. I checked the &lt;code&gt;WebViewController&lt;/code&gt; error callback — nothing. I checked the URL, the network, added logging to the navigation delegate. The page load was starting and immediately failing.&lt;/p&gt;

&lt;p&gt;Eventually I checked &lt;code&gt;AndroidManifest.xml&lt;/code&gt; and found the problem: there was no INTERNET permission.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;uses-permission&lt;/span&gt; &lt;span class="na"&gt;android:name=&lt;/span&gt;&lt;span class="s"&gt;"android.permission.INTERNET"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One line. The WebView was silently failing to load URLs because the app had no permission to access the internet on Android.&lt;/p&gt;

&lt;p&gt;This is easy to miss because packages like Dio and http add this permission automatically via manifest merging. &lt;code&gt;webview_flutter&lt;/code&gt; does not — you have to add it manually.&lt;/p&gt;

&lt;h2&gt;
  
  
  The lesson
&lt;/h2&gt;

&lt;p&gt;When something fails silently on Android, check the manifest before spending an hour on code-level debugging. &lt;code&gt;INTERNET&lt;/code&gt;, &lt;code&gt;CAMERA&lt;/code&gt;, &lt;code&gt;READ_EXTERNAL_STORAGE&lt;/code&gt; — these can all cause silent failures that look like bugs in your code when they are actually missing permissions.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Stateful vs Riverpod&lt;/strong&gt;: Use &lt;code&gt;ConsumerStatefulWidget&lt;/code&gt; when you have widget lifecycle state and Riverpod state in the same screen.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Manifest gotchas&lt;/strong&gt;: &lt;code&gt;webview_flutter&lt;/code&gt; requires the &lt;code&gt;INTERNET&lt;/code&gt; permission to be added manually to &lt;code&gt;AndroidManifest.xml&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Silent networking failures&lt;/strong&gt;: Check the Android manifest early when networking behaves unexpectedly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Next: Part 4 — Shipping v1.0.1 with GitHub Actions and a Changelog&lt;/em&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>android</category>
      <category>mobile</category>
      <category>dart</category>
    </item>
    <item>
      <title>Building a Flutter Shopping App — Part 3: Cloud Firestore and Push Notifications</title>
      <dc:creator>Yadnesh Teli</dc:creator>
      <pubDate>Mon, 19 Oct 2026 13:01:00 +0000</pubDate>
      <link>https://dev.to/yadneshteli/building-a-flutter-shopping-app-part-3-cloud-firestore-and-push-notifications-526f</link>
      <guid>https://dev.to/yadneshteli/building-a-flutter-shopping-app-part-3-cloud-firestore-and-push-notifications-526f</guid>
      <description>&lt;p&gt;&lt;em&gt;Series 1 of 2 — Part 3 of 5&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Building a Flutter Shopping App — Part 3: Cloud Firestore and Push Notifications
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;Series: Building a Flutter Shopping App — From Zero to Architecture&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;By this point the app had a working UI, Riverpod state management, and Firebase Auth. The next step was connecting it to a real backend — Firestore for user data persistence and Firebase Cloud Messaging for push notifications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Integrating Cloud Firestore
&lt;/h2&gt;

&lt;p&gt;I added &lt;code&gt;cloud_firestore&lt;/code&gt; to &lt;code&gt;pubspec.yaml&lt;/code&gt; and updated the plugin registrations. I used Firestore to persist user profile data and cart items server-side. The data structure was a top-level &lt;code&gt;users&lt;/code&gt; collection, keyed by Firebase Auth uid, with a &lt;code&gt;cart&lt;/code&gt; subcollection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;FirebaseFirestore&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;collection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'users'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;currentUser&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;uid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'cart'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cartItem&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toJson&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One thing that caught me out was plugin registration. After adding Firestore and other Firebase plugins, I had to make sure they were all properly registered for both platforms. Missing a registration does not always throw an obvious error — sometimes it silently fails to initialise.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up push notifications
&lt;/h2&gt;

&lt;p&gt;I integrated both Firebase Cloud Messaging and &lt;code&gt;flutter_local_notifications&lt;/code&gt;. FCM handles server-sent notifications. &lt;code&gt;flutter_local_notifications&lt;/code&gt; handles displaying them when the app is in the foreground, since FCM does not show a notification UI when the app is active.&lt;/p&gt;

&lt;p&gt;There are three scenarios to handle separately: app in foreground, app in background, and app terminated. Each has a different handler.&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="c1"&gt;// App foregrounded — show local notification&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;onMessageOpenedApp&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="c1"&gt;// App backgrounded — user tapped notification&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Saving and refreshing the FCM token
&lt;/h2&gt;

&lt;p&gt;For targeted notifications you need the device's FCM token saved in Firestore. I fetched and saved it after every login, and set up a token refresh listener because FCM tokens can change. If you do not update the stored token when it refreshes, notifications will eventually stop delivering.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Verify plugin registration&lt;/strong&gt;: Register all Firebase plugins explicitly — silent failures are harder to debug than crashes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Handle all notification states&lt;/strong&gt;: Push notifications have three separate states (foreground, background, terminated) and each needs its own handler.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Token lifecycle&lt;/strong&gt;: Save and refresh FCM tokens on every login, not just the first one.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Next: Part 4 — The Big Refactor: Migrating to MVVM with Repositories and ViewModels&lt;/em&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>firebase</category>
      <category>mobile</category>
      <category>dart</category>
    </item>
    <item>
      <title>Stop Bypassing SSL in Flutter: Solving the Missing Intermediate Certificate Nightmare with AIA Chasing</title>
      <dc:creator>Yadnesh Teli</dc:creator>
      <pubDate>Thu, 15 Oct 2026 10:30:00 +0000</pubDate>
      <link>https://dev.to/yadneshteli/stop-bypassing-ssl-in-flutter-solving-the-missing-intermediate-certificate-nightmare-with-aia-1gfo</link>
      <guid>https://dev.to/yadneshteli/stop-bypassing-ssl-in-flutter-solving-the-missing-intermediate-certificate-nightmare-with-aia-1gfo</guid>
      <description>&lt;h1&gt;
  
  
  Stop Bypassing SSL in Flutter: Solving the Missing Intermediate Certificate Nightmare with AIA Chasing
&lt;/h1&gt;

&lt;p&gt;Every Flutter developer has run into this maddening phantom bug at least once in their career:&lt;/p&gt;

&lt;p&gt;You open a client's API endpoint or an in-app WebView. In your desktop browser (Chrome, Edge, Safari), the URL loads smoothly with a reassuring green padlock. Everything looks clean and trusted.&lt;/p&gt;

&lt;p&gt;Then you test the exact same URL inside your Flutter app on Android:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HandshakeException: Handshake error in client (OS Error: 
  CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or if you're loading an in-app WebView with &lt;code&gt;webview_flutter&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;onReceivedSslError: primaryError: SSL_UNTRUSTED (net::ERR_CERT_AUTHORITY_INVALID)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You message the backend infrastructure team, and they show you a screenshot of Chrome: &lt;em&gt;"The certificate is valid, issued by a major authority (like Sectigo or DigiCert), and expires next year. The bug must be in your mobile app."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now you're stuck between a rock and a hard place. And that's usually the moment a well-meaning developer turns to StackOverflow and finds the &lt;strong&gt;worst advice in mobile engineering history&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Dangerous "Quick Fix" We Must Stop Doing
&lt;/h2&gt;

&lt;p&gt;Search for &lt;code&gt;CERTIFICATE_VERIFY_FAILED&lt;/code&gt; on StackOverflow, and the most upvoted answers will instruct you to add 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="c1"&gt;// ⚠️ NEVER DO THIS IN PRODUCTION:&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyHttpOverrides&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;HttpOverrides&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;HttpClient&lt;/span&gt; &lt;span class="n"&gt;createHttpClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SecurityContext&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;createHttpClient&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="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;badCertificateCallback&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X509Certificate&lt;/span&gt; &lt;span class="n"&gt;cert&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;host&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;port&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;true&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;Or in your WebView:&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="c1"&gt;// ⚠️ INSTANT SECURITY HOLE:&lt;/span&gt;
&lt;span class="nl"&gt;onReceivedSslError:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;handler&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;proceed&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Blindly accepts any certificate&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why this is a catastrophe
&lt;/h3&gt;

&lt;p&gt;Setting &lt;code&gt;badCertificateCallback = (...) =&amp;gt; true&lt;/code&gt; or unconditionally calling &lt;code&gt;proceed()&lt;/code&gt; &lt;strong&gt;completely eliminates TLS encryption verification&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;When you do this, your app will accept &lt;em&gt;any&lt;/em&gt; certificate — including a self-signed cert from an attacker sitting next to your user on public Wi-Fi running &lt;code&gt;mitmproxy&lt;/code&gt; or Charles Proxy. All authentication tokens, session cookies, passwords, and private PII can now be intercepted and decrypted in plaintext.&lt;/p&gt;

&lt;p&gt;Google Play's security scanner actively flags apps that call &lt;code&gt;handler.proceed()&lt;/code&gt; or disable &lt;code&gt;badCertificateCallback&lt;/code&gt;, leading to app rejections and suspensions.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Root Cause: Why Chrome Works and Mobile Fails
&lt;/h2&gt;

&lt;p&gt;To fix this properly without compromising security, we have to understand what is actually happening.&lt;/p&gt;

&lt;p&gt;As explained in &lt;a href="https://dev.to/merlonix/ssl-certificate-problem-unable-to-get-local-issuer-certificate-40ak"&gt;merlonix's breakdown of SSL issuer problems&lt;/a&gt;, web servers frequently send an &lt;strong&gt;incomplete certificate chain&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A server sends only its &lt;strong&gt;leaf certificate&lt;/strong&gt; (&lt;code&gt;cert.pem&lt;/code&gt;), omitting the &lt;strong&gt;intermediate certificate&lt;/strong&gt; (&lt;code&gt;chain.pem&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;The client's operating system only trusts &lt;strong&gt;Root CAs&lt;/strong&gt; (like USERTrust or DigiCert Global Root). It has never seen the specific Intermediate CA that signed this leaf cert.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Why does desktop Chrome work?
&lt;/h3&gt;

&lt;p&gt;Desktop browsers implement a feature defined in &lt;a href="https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.2.1" rel="noopener noreferrer"&gt;RFC 5280 §4.2.2.1&lt;/a&gt; called &lt;strong&gt;Authority Information Access (AIA)&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Chrome parses the leaf certificate's X.509 extensions and finds the &lt;code&gt;caIssuers&lt;/code&gt; URI (e.g., &lt;code&gt;http://crt.sectigo.com/SectigoRSADomainValidationSecureServerCA.crt&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Chrome quietly makes an HTTP &lt;code&gt;GET&lt;/code&gt; request in the background to download the missing intermediate certificate.&lt;/li&gt;
&lt;li&gt;It stitches the leaf, intermediate, and root together into a full cryptographic chain and verifies it against the OS root store.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Why does Flutter fail?
&lt;/h3&gt;

&lt;p&gt;Mobile runtimes — specifically &lt;code&gt;dart:io&lt;/code&gt; (&lt;code&gt;SecurityContext&lt;/code&gt;) and Android's native &lt;code&gt;TrustManager&lt;/code&gt; — &lt;strong&gt;do not implement AIA chasing by default&lt;/strong&gt;. They expect the server to provide the full chain (&lt;code&gt;fullchain.pem&lt;/code&gt;) in the TLS ServerHello handshake. When the server fails to do so, mobile clients throw &lt;code&gt;unable to get local issuer certificate&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;And often, you don't control the server! It might be a third-party payment gateway, an enterprise partner API, an exhibitor portal, or a legacy government service where submitting an IT ticket to update Nginx/Apache takes three months.&lt;/p&gt;




&lt;h2&gt;
  
  
  Enter AIA Chaser: Automated, Scoped Certificate Chasing for Flutter
&lt;/h2&gt;

&lt;p&gt;Rather than choosing between a broken app and a gaping security hole, I built and open-sourced &lt;strong&gt;&lt;a href="https://pub.dev/packages/aia_chaser" rel="noopener noreferrer"&gt;AIA Chaser&lt;/a&gt;&lt;/strong&gt; (&lt;code&gt;aia_chaser&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;AIA Chaser brings desktop-grade Authority Information Access chasing directly into Flutter and Android, &lt;strong&gt;without disabling certificate validation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff023sr7v3x0hem2tl2rc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff023sr7v3x0hem2tl2rc.jpg" alt="AIA Certificate Chain Completion Diagram" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Principles
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Cryptographic Integrity First&lt;/strong&gt;: It &lt;em&gt;never&lt;/em&gt; blind-accepts untrusted certificates. If a certificate is self-signed, expired, forged, or belongs to an unlisted host, it is &lt;strong&gt;strictly rejected&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Host-Scoped Policies&lt;/strong&gt;: You explicitly define which hostnames or wildcards (&lt;code&gt;*.example.com&lt;/code&gt;) are allowed to chase certificates.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Microsecond In-Memory Cache&lt;/strong&gt;: Chased certificates are held in an in-memory leaf store. Once validated, subsequent requests hit cache in &lt;strong&gt;1–3ms&lt;/strong&gt; with zero network overhead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Persistent LRU Disk Cache&lt;/strong&gt;: Validated intermediates are stored in an encrypted/private disk cache so cold app restarts don't re-download certificates over cellular networks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero-Latency Prewarming&lt;/strong&gt;: Validate your mission-critical endpoints during app startup in the background (&lt;code&gt;PrewarmMode.background&lt;/code&gt;) so user-facing calls never wait on an AIA fetch.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  The Complete Ecosystem
&lt;/h2&gt;

&lt;p&gt;AIA Chaser is modular and published across 4 companion packages on &lt;code&gt;pub.dev&lt;/code&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Package&lt;/th&gt;
&lt;th&gt;Pub.dev Score&lt;/th&gt;
&lt;th&gt;Role&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;a href="https://pub.dev/packages/aia_chaser" rel="noopener noreferrer"&gt;&lt;code&gt;aia_chaser&lt;/code&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;150 / 160&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Core engine, Pigeon IPC platform channel, Android &lt;code&gt;TrustManager&lt;/code&gt; validator, cache, and diagnostic view.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;a href="https://pub.dev/packages/aia_chaser_dio" rel="noopener noreferrer"&gt;&lt;code&gt;aia_chaser_dio&lt;/code&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;160 / 160&lt;/strong&gt; 🎯&lt;/td&gt;
&lt;td&gt;Custom &lt;code&gt;HttpClientAdapter&lt;/code&gt; for &lt;code&gt;dio&lt;/code&gt; with transparent retry-once resilience.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;a href="https://pub.dev/packages/aia_chaser_http" rel="noopener noreferrer"&gt;&lt;code&gt;aia_chaser_http&lt;/code&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;160 / 160&lt;/strong&gt; 🎯&lt;/td&gt;
&lt;td&gt;Drop-in &lt;code&gt;http.BaseClient&lt;/code&gt; for &lt;code&gt;package:http&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;a href="https://pub.dev/packages/aia_chaser_webview" rel="noopener noreferrer"&gt;&lt;code&gt;aia_chaser_webview&lt;/code&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;160 / 160&lt;/strong&gt; 🎯&lt;/td&gt;
&lt;td&gt;Safe Android &lt;code&gt;onReceivedSslError&lt;/code&gt; handler for &lt;code&gt;webview_flutter&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Quick Start (Less than 10 Lines)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Installation
&lt;/h3&gt;

&lt;p&gt;In your &lt;code&gt;pubspec.yaml&lt;/code&gt;:&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;aia_chaser&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;^0.1.0&lt;/span&gt;
  &lt;span class="na"&gt;aia_chaser_dio&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;^0.1.0&lt;/span&gt;
  &lt;span class="na"&gt;aia_chaser_webview&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;^0.1.0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Initialize in &lt;code&gt;main.dart&lt;/code&gt;
&lt;/h3&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:io'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:flutter/material.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:aia_chaser/aia_chaser.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;AiaChaser&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;initialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;AiaConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="c1"&gt;// Pre-validates hosts at startup in background:&lt;/span&gt;
      &lt;span class="nl"&gt;prewarm:&lt;/span&gt; &lt;span class="n"&gt;PrewarmMode&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;background&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;hosts:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s"&gt;'api.partner-service.com'&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;HostPolicy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;chase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;retryOnce:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="s"&gt;'*.exhibitor-portal.in'&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;HostPolicy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;chase&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="c1"&gt;// Installs safe global dart:io overrides&lt;/span&gt;
  &lt;span class="n"&gt;HttpOverrides&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;global&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;AiaHttpOverrides&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="kd"&gt;const&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;
  
  
  3. Safe Android WebView Integration
&lt;/h3&gt;

&lt;p&gt;Instead of calling &lt;code&gt;handler.proceed()&lt;/code&gt; blindly in &lt;code&gt;onReceivedSslError&lt;/code&gt;, let AIA Chaser verify the chain first:&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:aia_chaser_webview/aia_chaser_webview.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:webview_flutter/webview_flutter.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:webview_flutter_android/webview_flutter_android.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;WebViewController&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setNavigationDelegate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;NavigationDelegate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="c1"&gt;// Standard navigation handling...&lt;/span&gt;
    &lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Wire safe AIA verification into Android WebView&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;controller&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;platform&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="n"&gt;AndroidWebViewController&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;AiaWebViewHandler&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;install&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;platform&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;AndroidWebViewController&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the server sends a partial chain, &lt;code&gt;AiaWebViewHandler&lt;/code&gt; will:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Intercept &lt;code&gt;SSL_UNTRUSTED&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Extract the leaf cert and chase the intermediate.&lt;/li&gt;
&lt;li&gt;Validate against Android's system trust store (&lt;code&gt;X509TrustManagerExtensions&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Only call &lt;code&gt;proceed()&lt;/code&gt; if the chain is &lt;strong&gt;cryptographically verified&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Otherwise, safely reject the connection and display your custom error UI.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Real-World Production Case Study
&lt;/h2&gt;

&lt;p&gt;We recently deployed AIA Chaser in a production trade-expo companion app (&lt;strong&gt;ACREX India&lt;/strong&gt;). &lt;/p&gt;

&lt;p&gt;The event portal (&lt;code&gt;register.acrex.in&lt;/code&gt;) hosted real-time exhibitor directories (254 exhibitors) and interactive 3D floorplan WebViews. The server's SSL certificate was missing the Sectigo RSA intermediate certificate.&lt;/p&gt;

&lt;p&gt;Prior to AIA Chaser:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The app was intermittently crashing with &lt;code&gt;HandshakeException: CERTIFICATE_VERIFY_FAILED&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;In-app WebViews were failing with white screens and &lt;code&gt;SSL_UNTRUSTED&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After installing &lt;code&gt;aia_chaser: ^0.1.0&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On cold boot, both &lt;code&gt;acrex.in&lt;/code&gt; and &lt;code&gt;register.acrex.in&lt;/code&gt; were prewarmed in the background.&lt;/li&gt;
&lt;li&gt;Subsequent API requests and WebViews reported:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  [AiaChaser] Prewarmed acrex.in -&amp;gt; ValidationOutcome.validated (3ms - In-memory cache hit)
  [AiaChaser] Prewarmed register.acrex.in -&amp;gt; ValidationOutcome.validated (1ms - In-memory cache hit)
  &amp;lt;-- 200 https://register.acrex.in/ACREXService.svc/GetSliderList
  &amp;lt;-- 200 https://register.acrex.in/ACREXService.svc/SearchExhibitorNew (254 items loaded)
  ✅ [WEBVIEW PAGE FINISHED] Loaded URL: https://register.acrex.in/hallLayout/...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Zero handshake exceptions, zero insecure bypasses, and 100% data fidelity.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Built-In Diagnostics Widget
&lt;/h2&gt;

&lt;p&gt;Need to inspect what certificates were chased or verify cache hits? AIA Chaser includes a Flutter Material 3 diagnostic inspector:&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;Navigator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;MaterialPageRoute&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;_&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;AiaDiagnosticsView&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;It gives you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Visual host list with green/red status indicators.&lt;/li&gt;
&lt;li&gt;Cache hit/miss counts and probe latency (in milliseconds).&lt;/li&gt;
&lt;li&gt;Subject, Issuer, Serial Number, and SHA-256 fingerprint of all intercepted certs.&lt;/li&gt;
&lt;li&gt;"Flush Cache" and "Prewarm All" actions for real-time testing.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Conclusion &amp;amp; Community Wisdom
&lt;/h2&gt;

&lt;p&gt;Missing intermediate certificates are one of the most frustrating pain points in mobile development because desktop browsers hide the problem, leaving mobile developers feeling like it's a bug in Flutter or Android.&lt;/p&gt;

&lt;p&gt;Bypassing verification with &lt;code&gt;badCertificateCallback = (...) =&amp;gt; true&lt;/code&gt; is never the answer. &lt;/p&gt;

&lt;p&gt;With &lt;strong&gt;AIA Chaser&lt;/strong&gt;, you get desktop-grade TLS resilience while maintaining strict cryptographic security.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Repository&lt;/strong&gt;: &lt;a href="https://github.com/YadneshTeli/aia_chaser" rel="noopener noreferrer"&gt;https://github.com/YadneshTeli/aia_chaser&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pub.dev Package&lt;/strong&gt;: &lt;a href="https://pub.dev/packages/aia_chaser" rel="noopener noreferrer"&gt;https://pub.dev/packages/aia_chaser&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Give it a star on GitHub, try it in your projects, and never let an incomplete SSL certificate chain take your mobile app down again!&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>security</category>
      <category>android</category>
      <category>mobile</category>
    </item>
    <item>
      <title>Building DevFeed — Part 2: The Feed, Hacker News API, and Riverpod AsyncNotifier</title>
      <dc:creator>Yadnesh Teli</dc:creator>
      <pubDate>Wed, 14 Oct 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/yadneshteli/building-devfeed-part-2-the-feed-hacker-news-api-and-riverpod-asyncnotifier-4o9a</link>
      <guid>https://dev.to/yadneshteli/building-devfeed-part-2-the-feed-hacker-news-api-and-riverpod-asyncnotifier-4o9a</guid>
      <description>&lt;p&gt;&lt;em&gt;Series 2 of 2 — Part 2 of 4&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Building DevFeed — Part 2: The Feed, Hacker News API, and Riverpod AsyncNotifier
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;Series: Building DevFeed — A Proper Flutter MVVM App from Day One&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;With the architecture in place from Part 1, it was time to build the actual feature — fetching Hacker News stories and displaying them. This post covers the repository implementation, the data fetching strategy, and why &lt;code&gt;AsyncNotifier&lt;/code&gt; is the right Riverpod primitive for a feed with pull-to-refresh.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Hacker News API
&lt;/h2&gt;

&lt;p&gt;The API is public, free, and needs no authentication. The top stories endpoint returns an array of item IDs, and then you fetch each item individually for its details.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;// Step 1: fetch top story IDs
GET https://hacker-news.firebaseio.com/v0/topstories.json
// Returns: [34562341, 34560198, ...]

// Step 2: fetch each item
GET https://hacker-news.firebaseio.com/v0/item/{id}.json
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you fetch all IDs and then fetch each item sequentially, loading the feed takes a long time. The fix is &lt;code&gt;Future.wait&lt;/code&gt; for parallel fetching.&lt;/p&gt;

&lt;h2&gt;
  
  
  The repository with parallel fetching
&lt;/h2&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;HackerNewsRepository&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;Dio&lt;/span&gt; &lt;span class="n"&gt;_dio&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="n"&gt;HackerNewsRepository&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="kd"&gt;required&lt;/span&gt; &lt;span class="n"&gt;Dio&lt;/span&gt; &lt;span class="n"&gt;dio&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;_dio&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dio&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;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ArticleModel&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;fetchTopStories&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;limit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="kd"&gt;async&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;idsResponse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;_dio&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="s"&gt;'https://hacker-news.firebaseio.com/v0/topstories.json'&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;ids&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;idsResponse&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;take&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;cast&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="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;articles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;Future&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ids&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;_fetchItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&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;articles&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;whereType&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ArticleModel&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toList&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="n"&gt;ArticleModel&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;_fetchItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;async&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;_dio&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="s"&gt;'https://hacker-news.firebaseio.com/v0/item/&lt;/span&gt;&lt;span class="si"&gt;$id&lt;/span&gt;&lt;span class="s"&gt;.json'&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&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;ArticleModel&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fromJson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&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;I used &lt;code&gt;Dio&lt;/code&gt; rather than the built-in &lt;code&gt;http&lt;/code&gt; package for its interceptors, request cancellation, and cleaner error handling. The repository takes &lt;code&gt;Dio&lt;/code&gt; in its constructor for easy testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  AsyncNotifier vs FutureProvider
&lt;/h2&gt;

&lt;p&gt;Riverpod offers two main options for async state. &lt;code&gt;FutureProvider&lt;/code&gt; is simpler — define a function returning a Future, Riverpod handles the &lt;code&gt;AsyncValue&lt;/code&gt; wrapping. &lt;code&gt;AsyncNotifier&lt;/code&gt; gives you more control — you expose methods like refresh alongside the state.&lt;/p&gt;

&lt;p&gt;For a feed with pull-to-refresh, &lt;code&gt;AsyncNotifier&lt;/code&gt; is the right choice. The refresh method sets state to &lt;code&gt;AsyncLoading&lt;/code&gt; then re-fetches, which drives the loading indicator in the UI.&lt;/p&gt;

&lt;h2&gt;
  
  
  The feed screen
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;FeedScreen&lt;/code&gt; watches &lt;code&gt;feedViewModelProvider&lt;/code&gt; and uses &lt;code&gt;.when&lt;/code&gt; to render the correct UI:&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;feedAsync&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;feedViewModelProvider&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;feedAsync&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;loading:&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;CircularProgressIndicator&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
  &lt;span class="nl"&gt;error:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;ErrorWidget&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt;
  &lt;span class="nl"&gt;data:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;articles&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;ArticleList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;articles:&lt;/span&gt; &lt;span class="n"&gt;articles&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 screen has no knowledge of Dio, the API URL, or how articles are fetched. It just renders what the ViewModel provides.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Parallelize I/O&lt;/strong&gt;: &lt;code&gt;Future.wait&lt;/code&gt; for parallel item fetching makes a real difference in feed load speed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Choose the right provider&lt;/strong&gt;: &lt;code&gt;AsyncNotifier&lt;/code&gt; is the right choice when you need to expose methods alongside async state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inject HTTP clients&lt;/strong&gt;: Injecting Dio through Riverpod centralises configuration and makes testing straightforward.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Next: Part 3 — In-app WebView, Sharing Actions, and the Android INTERNET Permission&lt;/em&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>api</category>
      <category>riverpod</category>
      <category>dart</category>
    </item>
  </channel>
</rss>
