<?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: Muhammad Tahir</title>
    <description>The latest articles on DEV Community by Muhammad Tahir (@mtahir27).</description>
    <link>https://dev.to/mtahir27</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%2F1005213%2F962a1a19-bc34-4bc5-8085-102c177de1ad.png</url>
      <title>DEV Community: Muhammad Tahir</title>
      <link>https://dev.to/mtahir27</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mtahir27"/>
    <language>en</language>
    <item>
      <title>I Built a Full-Stack Flutter Expense Splitting App — Here's What I Learned</title>
      <dc:creator>Muhammad Tahir</dc:creator>
      <pubDate>Fri, 21 Aug 2026 17:10:56 +0000</pubDate>
      <link>https://dev.to/mtahir27/i-built-a-full-stack-flutter-expense-splitting-app-heres-what-i-learned-5gn3</link>
      <guid>https://dev.to/mtahir27/i-built-a-full-stack-flutter-expense-splitting-app-heres-what-i-learned-5gn3</guid>
      <description>&lt;p&gt;After months of coding nights and weekends, I finally shipped &lt;strong&gt;Expenses Meet&lt;/strong&gt; to the Google Play Store — a collaborative, offline-first group expense splitter and personal finance tracker built entirely with Flutter.&lt;/p&gt;

&lt;p&gt;In this post I want to share &lt;em&gt;why&lt;/em&gt; I built it, the architectural decisions that shaped it, the painful mistakes, and the features I'm most proud of.&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 Why I Built It
&lt;/h2&gt;

&lt;p&gt;Every time I travel with friends or split rent with roommates, the same conversation happens:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Wait, who paid for dinner?"&lt;/em&gt;&lt;br&gt;
&lt;em&gt;"Didn't you already pay me back for that?"&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Apps like Splitwise exist, but I wanted something that also doubles as a &lt;strong&gt;personal ledger&lt;/strong&gt; — a single place where I can track my own transactions AND handle group bills simultaneously. So I built Expenses Meet.&lt;/p&gt;




&lt;h2&gt;
  
  
  🏗️ Architecture at a Glance
&lt;/h2&gt;

&lt;p&gt;The app follows a &lt;strong&gt;feature-first folder structure&lt;/strong&gt; with BLoC as the state management layer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lib/
├── core/           # Shared utilities, constants, routing
├── features/
│   ├── transactions/
│   ├── groups/
│   ├── loans/
│   └── settings/
└── main.dart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Offline-First with Hive + Firestore Sync
&lt;/h3&gt;

&lt;p&gt;The biggest architectural decision was going &lt;strong&gt;offline-first&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All data is persisted locally in &lt;strong&gt;Hive&lt;/strong&gt; (a fast, lightweight NoSQL store for Flutter).&lt;/li&gt;
&lt;li&gt;When the user comes online, a &lt;code&gt;SyncService&lt;/code&gt; pushes local changes to &lt;strong&gt;Cloud Firestore&lt;/strong&gt; and pulls remote changes down.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The tricky part? Preventing data loss during sync. My first naive implementation would wipe local Hive boxes before writing remote data — which meant un-synced local edits got destroyed on refresh. 😬&lt;/p&gt;

&lt;p&gt;The fix was to run &lt;code&gt;syncLocalToCloud()&lt;/code&gt; &lt;em&gt;before&lt;/em&gt; &lt;code&gt;syncCloudToLocal()&lt;/code&gt;, rescue any pending local items, and restore them after the download. Obvious in hindsight, brutal to debug.&lt;/p&gt;

&lt;h3&gt;
  
  
  State Management: BLoC + Freezed
&lt;/h3&gt;

&lt;p&gt;Every feature uses &lt;code&gt;flutter_bloc&lt;/code&gt; with &lt;code&gt;Freezed&lt;/code&gt; models. Freezed gives me:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Immutable data classes&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;copyWith&lt;/code&gt; for free&lt;/li&gt;
&lt;li&gt;Pattern matching on states&lt;/li&gt;
&lt;li&gt;Generated Hive adapters&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One important gotcha I hit: &lt;strong&gt;Hive field indices and backward compatibility&lt;/strong&gt;. When adding a new non-nullable field to an existing Hive model, you &lt;em&gt;must&lt;/em&gt; add &lt;code&gt;defaultValue:&lt;/code&gt; on the &lt;code&gt;@HiveField&lt;/code&gt; annotation:&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;// ✅ Correct — won't crash on existing data&lt;/span&gt;
&lt;span class="nd"&gt;@HiveField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;defaultValue:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@Default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;isPending&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

&lt;span class="c1"&gt;// ❌ Wrong — crashes with "type 'Null' is not a subtype of type 'bool'"&lt;/span&gt;
&lt;span class="nd"&gt;@HiveField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@Default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;isPending&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Freezed's &lt;code&gt;@Default&lt;/code&gt; only fires in the constructor — it doesn't help the Hive adapter when a field is missing from disk. I learned this the hard way after a production crash report.&lt;/p&gt;




&lt;h2&gt;
  
  
  ✨ Key Features
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Group Expense Splitting
&lt;/h3&gt;

&lt;p&gt;Add a bill, choose a payer, and split it three ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Equally&lt;/strong&gt; — divide among selected members&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exact amounts&lt;/strong&gt; — assign custom amounts per person&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Percentages&lt;/strong&gt; — weighted splits (60/40, etc.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The settle-up engine computes &lt;strong&gt;minimum transactions&lt;/strong&gt; to zero out all debts in a group, instead of tracking each individual IOU.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Personal Ledger + Linked Records
&lt;/h3&gt;

&lt;p&gt;Every group action (expense paid, settlement, loan) automatically creates a matching record in your &lt;strong&gt;personal transaction history&lt;/strong&gt;, fully linked so you can tap through from your ledger to the group context and vice versa.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Loans &amp;amp; Debt Tracking
&lt;/h3&gt;

&lt;p&gt;Peer-to-peer loans with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Role-aware UI (lender vs borrower see different actions)&lt;/li&gt;
&lt;li&gt;Installment schedules with cadence tracking&lt;/li&gt;
&lt;li&gt;Repayment approval flow — counterparty must accept before the balance updates&lt;/li&gt;
&lt;li&gt;Push notifications for edits, deletions, and reminders&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. App Security
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Biometric / PIN lock with a 30-second grace period (so switching apps briefly doesn't lock you out)&lt;/li&gt;
&lt;li&gt;Balance masking in Privacy Mode&lt;/li&gt;
&lt;li&gt;Inline PIN pad on the lock screen (no modal sheets that bleed behind the lock overlay)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. Real-Time Push Notifications (FCM)
&lt;/h3&gt;

&lt;p&gt;Getting push notifications right on Android was the hardest single feature. Key lessons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Register &lt;code&gt;FirebaseMessaging.onBackgroundMessage&lt;/code&gt; as a &lt;strong&gt;top-level function&lt;/strong&gt; (not a method), or Android ignores it.&lt;/li&gt;
&lt;li&gt;Tapping a notification while the app is cold-starting requires a &lt;strong&gt;pending click queue&lt;/strong&gt; — you can't navigate until the widget tree is mounted.&lt;/li&gt;
&lt;li&gt;Always add &lt;code&gt;FLUTTER_NOTIFICATION_CLICK&lt;/code&gt; intent filter to &lt;code&gt;AndroidManifest.xml&lt;/code&gt; or notification taps do nothing on some Android versions.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🛠️ Tech Stack
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Library&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;UI Framework&lt;/td&gt;
&lt;td&gt;Flutter 3.x + Dart 3.x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;State Management&lt;/td&gt;
&lt;td&gt;&lt;code&gt;flutter_bloc&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Local DB&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;hive&lt;/code&gt; + &lt;code&gt;hive_flutter&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Remote DB&lt;/td&gt;
&lt;td&gt;Cloud Firestore&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Auth&lt;/td&gt;
&lt;td&gt;Firebase Auth&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Push Notifications&lt;/td&gt;
&lt;td&gt;Firebase Cloud Messaging (FCM)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Crash Reporting&lt;/td&gt;
&lt;td&gt;Firebase Crashlytics&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Navigation&lt;/td&gt;
&lt;td&gt;&lt;code&gt;go_router&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Charts&lt;/td&gt;
&lt;td&gt;&lt;code&gt;fl_chart&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Models&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;freezed&lt;/code&gt; + &lt;code&gt;json_serializable&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PDF Export&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;pdf&lt;/code&gt; package&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Biometrics&lt;/td&gt;
&lt;td&gt;&lt;code&gt;local_auth&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Typography&lt;/td&gt;
&lt;td&gt;Outfit (Google Fonts)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  📉 Mistakes &amp;amp; Lessons
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Hive key ranges matter.&lt;/strong&gt;&lt;br&gt;
Never use &lt;code&gt;DateTime.now().millisecondsSinceEpoch&lt;/code&gt; as a Hive integer key — it exceeds 32 bits and throws &lt;code&gt;HiveError&lt;/code&gt;. Use &lt;code&gt;millisecondsSinceEpoch ~/ 1000&lt;/code&gt; instead, and check for collisions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Keyboard animation performance.&lt;/strong&gt;&lt;br&gt;
Wrapping the entire screen in a single &lt;code&gt;setState&lt;/code&gt; listener for keyboard insets caused 60fps drops on every keystroke. The fix: isolate &lt;code&gt;MediaQuery.viewInsetsOf(context)&lt;/code&gt; into a tiny wrapper widget and use &lt;code&gt;ValueListenableBuilder&lt;/code&gt; for text controllers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. GlobalKey ownership with overlays.&lt;/strong&gt;&lt;br&gt;
Using &lt;code&gt;GlobalKey&lt;/code&gt;s inside route-transitioning widgets + a &lt;code&gt;ShowCaseWidget&lt;/code&gt; overlay caused &lt;code&gt;Multiple widgets used the same GlobalKey&lt;/code&gt; crashes on every notification tap. Root cause: the showcase widget was being re-parented during navigation. Fix: move &lt;code&gt;ShowCaseWidget&lt;/code&gt; to wrap the app root in &lt;code&gt;main.dart&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Settle up, then communicate.&lt;/strong&gt;&lt;br&gt;
I built the whole settle-up calculation engine before building the share/receipt feature. Big mistake — the data shape the settle-up engine produces doesn't map cleanly to what users want to share in a WhatsApp message. Design the output format first.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 What's Next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;iOS App Store release&lt;/li&gt;
&lt;li&gt;CSV / Google Sheets export&lt;/li&gt;
&lt;li&gt;Recurring transaction reminders&lt;/li&gt;
&lt;li&gt;Widgets for the home screen (foundation already in with &lt;code&gt;home_widget&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Try It
&lt;/h2&gt;

&lt;p&gt;📱 &lt;strong&gt;Google Play Store&lt;/strong&gt;: &lt;a href="https://play.google.com/store/apps/details?id=com.tahir.expensesmeet" rel="noopener noreferrer"&gt;Expenses Meet&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you've built something similar or have questions about the offline-sync architecture or the BLoC patterns, drop a comment below — happy to dig into any of it.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Built with Flutter · Firebase · Hive · ❤️&lt;/em&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>firebase</category>
      <category>dart</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Flutter IOS app error during building ipa file</title>
      <dc:creator>Muhammad Tahir</dc:creator>
      <pubDate>Tue, 10 Jan 2023 09:15:13 +0000</pubDate>
      <link>https://dev.to/mtahir27/flutter-ios-app-error-during-building-ipa-file-5h61</link>
      <guid>https://dev.to/mtahir27/flutter-ios-app-error-during-building-ipa-file-5h61</guid>
      <description>&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.amazonaws.com%2Fuploads%2Farticles%2Femge78e2cfu2hxh7ryg0.png" 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.amazonaws.com%2Fuploads%2Farticles%2Femge78e2cfu2hxh7ryg0.png" alt=" " width="799" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ios</category>
      <category>errors</category>
      <category>flutter</category>
    </item>
  </channel>
</rss>
