<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Morel Denzel on Medium]]></title>
        <description><![CDATA[Stories by Morel Denzel on Medium]]></description>
        <link>https://medium.com/@moreldenzel?source=rss-2e69e67ee71d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0M3Aau6BWg17lSbWecKAzg.png</url>
            <title>Stories by Morel Denzel on Medium</title>
            <link>https://medium.com/@moreldenzel?source=rss-2e69e67ee71d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 13:00:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@moreldenzel/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building Kora: A System for Trust in NGO & Humanitarian Operations]]></title>
            <link>https://moreldenzel.medium.com/building-kora-a-system-for-trust-in-ngo-humanitarian-operations-376000047ef3?source=rss-2e69e67ee71d------2</link>
            <guid isPermaLink="false">https://medium.com/p/376000047ef3</guid>
            <category><![CDATA[ngo]]></category>
            <category><![CDATA[systems-thinking]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[saas]]></category>
            <dc:creator><![CDATA[Morel Denzel]]></dc:creator>
            <pubDate>Sun, 12 Apr 2026 12:29:04 GMT</pubDate>
            <atom:updated>2026-04-12T12:29:04.845Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3L6aboH7q5w9VPujM3a1Vw.png" /></figure><p>Most software projects start with features.</p><p>Kora didn’t.<br>It started with a question:</p><blockquote>How do you create trust in environments where data is fragile, operations are distributed, and accountability is critical?</blockquote><p>Kora is a SaaS platform designed for NGOs to digitize and manage field operations, from beneficiary registration to aid delivery, within a structured, verifiable system.</p><p>But more than that, it’s an attempt to solve a deeper problem:</p><p><strong>Not just managing data but making that data reliable.</strong></p><h3>From Features to Systems</h3><p>One of the key decisions I made early was:</p><blockquote><em>Don’t build a feature-based app. Build a </em><strong><em>system of accountability</em></strong><em>.</em></blockquote><p>That led to a role-based architecture where each actor has a clear responsibility and no single person controls the entire flow.</p><h3>The Structure</h3><p>Kora operates across:</p><ul><li>a <strong>web platform</strong> for coordination and oversight</li><li>a <strong>mobile app (Kora Field)</strong> for field execution</li></ul><p>And three core roles:</p><ul><li><strong>Admins</strong> → define projects, structure operations, and maintain oversight</li><li><strong>Collaborators</strong> → validate field data and enforce quality</li><li><strong>Enumerators</strong> → collect data and execute operations in the field</li></ul><p>This separation isn’t just organizational.<br>It’s <strong>architectural</strong>.</p><p>It ensures that every piece of data goes through a controlled and verifiable process.</p><h3>The Workflow: A Chain of Trust</h3><p>Kora’s workflow is intentionally strict:</p><ol><li>Projects are created with defined assistance types</li><li>Enumerators register beneficiaries in the field</li><li>Data is synchronized and submitted</li><li>Collaborators review and approve or reject records</li><li>Only validated beneficiaries can receive recorded aid</li><li>Every action is logged and exportable</li></ol><p>This creates something critical:</p><blockquote><em>A </em><strong><em>chain of custody for data</em></strong></blockquote><p>Every record:</p><ul><li>has an origin</li><li>has a reviewer</li><li>has a history</li></ul><h3>Engineering for Real-World Constraints</h3><p>Building Kora wasn’t about choosing technologies, it was about designing for reality.</p><h4>Offline-First by Necessity</h4><p>Field agents often operate in low-connectivity environments.</p><p>So the system:</p><ul><li>handles operations offline</li><li>stores actions locally</li><li>synchronizes safely when possible</li></ul><p>If your system doesn’t work offline, it doesn’t work in the field.</p><h4>Validation as a Core Mechanism</h4><p>Validation is not optional in Kora, it’s foundational.</p><ul><li>No beneficiary is usable until approved</li><li>No delivery exists without validation</li><li>Every rejection includes feedback</li></ul><p>This enforces quality at the system level, not at the user level.</p><h3>Built-In Auditability</h3><p>Every action is:</p><ul><li>tied to a user</li><li>scoped to a role</li><li>linked to a project</li></ul><p>This makes reporting not just easier, but defensible.</p><h3>Beyond a Dashboard</h3><p>Kora is not a reporting tool.</p><p>It’s an <strong>operational system</strong>.</p><p>Reports and exports exist because:</p><ul><li>the data is structured</li><li>the workflow is controlled</li><li>the validation is enforced</li></ul><p>Not the other way around.</p><h3>Why This Matters</h3><p>For NGOs, this isn’t just about efficiency.</p><p>It’s about:</p><ul><li><strong>reducing errors in the field</strong></li><li><strong>preventing fraud or inconsistencies</strong></li><li><strong>improving internal coordination</strong></li><li><strong>building trust with donors and partners</strong></li></ul><p>Because at the end of the day:</p><blockquote><em>If your data isn’t trusted, your impact is questioned.</em></blockquote><h3>What Kora Represents</h3><p>This project pushed me beyond just building applications.</p><p>It forced me to think in terms of:</p><ul><li>systems, not screens</li><li>workflows, not endpoints</li><li>trust, not just functionality</li></ul><p>Kora is part of a larger vision:</p><blockquote><em>Building technology that supports </em><strong><em>real-world operations with real consequences</em></strong><em>.</em></blockquote><h3>Exploring Kora</h3><p>Kora is already live and evolving.</p><p>If you’re part of an NGO, or working in field operations, you can explore it here:</p><p>👉 <a href="https://www.kora.onl/">https://www.kora.onl</a></p><p>I’m particularly interested in connecting with:</p><ul><li>organisations managing field data</li><li>teams dealing with reporting and accountability challenges</li><li>operators who understand the realities on the ground</li></ul><h3>Final Thoughts</h3><p>There’s a difference between building software and building systems people can rely on.</p><p>Kora aims to be the latter.</p><p>Not perfect.<br>Not finished.<br>But intentional.</p><p>And that’s the direction I’m committed to.</p><p>In many NGOs, field operations still rely on:</p><ul><li>paper-based records</li><li>scattered spreadsheets</li><li>delayed reporting cycles</li><li>limited visibility between teams</li></ul><p>But the real issue isn’t inefficiency</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=376000047ef3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From App Code to Reusable Package: How I Built My Own Flutter Package]]></title>
            <link>https://moreldenzel.medium.com/from-app-code-to-reusable-package-how-i-built-my-own-flutter-package-86399af8310f?source=rss-2e69e67ee71d------2</link>
            <guid isPermaLink="false">https://medium.com/p/86399af8310f</guid>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[dart-programming-language]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[pack]]></category>
            <category><![CDATA[flutter-package]]></category>
            <dc:creator><![CDATA[Morel Denzel]]></dc:creator>
            <pubDate>Mon, 02 Feb 2026 20:28:33 GMT</pubDate>
            <atom:updated>2026-02-02T20:28:33.756Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ydw3VZTjW0uuY2r37AoLEg.png" /></figure><p>I’ve been building Flutter apps for a while now, and there always comes that moment when you copy-paste the same piece of code into three different projects. You know the feeling “Okay, this custom button / loader / validator works great… why am I doing this again?”</p><p>That happened to me recently. I had this smooth navigation route with varieties of animations that I kept reusing. Instead of keeping it trapped inside one app, I decided to turn it into a proper Flutter package.</p><p>Here’s how I went from messy app code to something clean and reusable step by step. Nothing super advanced, just the practical stuff I wish someone had told me the first time.</p><h3>Step 1: Pull the code out and create a package project</h3><p>I started by making a fresh package instead of hacking an existing app. In the terminal:</p><pre>flutter create --template=package my_cool_widget<br>cd my_cool_widget</pre><p>This gives you a clean skeleton:</p><ul><li>lib/my_cool_widget.dart (your main file that people will import)</li><li>pubspec.yaml</li><li>a test/ folder ready for tests</li></ul><p>Right away I renamed things to match my package name and updated the description in pubspec.yaml. Small thing, but it makes everything feel intentional.</p><pre>name: my_cool_widget<br>description: A customizable animated widget with validation feedback for Flutter forms.<br>version: 0.1.0<br>homepage: https://github.com/yourusername/my_cool_widget</pre><p>Add your GitHub link early it helps people trust the package later if your feel like publishing it on pub.dev.</p><h3>Step 2: Organize the code properly (the part that shows maturity)</h3><p>I didn’t just dump everything into one file. Inside lib/ I created a src/ folder for the real implementation (this is a common pattern so users only see the clean public API).</p><p>So the structure looked like:</p><pre>lib/<br>├── my_cool_widget.dart          ← only exports<br>└── src/<br>    ├── my_cool_widget.dart      ← the actual widget code<br>    ├── utils/<br>    │   └── helpers.dart<br>    └── models/<br>        └── validation_result.dart</pre><p>In the top-level my_cool_widget.dart I just export what people need:</p><pre>export &#39;src/my_cool_widget.dart&#39;;</pre><p>This keeps the public surface small and clean. Users do import ‘package:my_cool_widget/my_cool_widget.dart’; and get only what they should.</p><h3>Step 3: Write it like production code</h3><p>I treated this package the way I’d want if I was using someone else’s:</p><ul><li>Added good parameter names and default values</li><li>Made it null-safe (of course)</li><li>Used constants where it made sense</li><li>Added documentation comments on public classes/methods Flutter’s analyzer shows them nicely in IDEs</li></ul><p>Example:</p><pre>/// A customizable animated input field that shakes on error.<br>///<br>/// [onChanged] callback for value changes<br>/// [validator] optional function that returns error message or null<br>class CoolAnimatedField extends StatefulWidget {<br>  final ValueChanged&lt;String&gt;? onChanged;<br>  final String? Function(String?)? validator;<br>  // ...<br>}</pre><h3>Step 4: Actually test it (yes, even small packages)</h3><p>I used to skip this… big mistake. Tests give confidence when you change things later.</p><p>I wrote a few basic widget tests in test/my_cool_widget_test.dart:</p><ul><li>Does it render without crashing?</li><li>Does the validator show error message?</li><li>Does the animation trigger?</li></ul><p>Running flutter test became part of my routine before every commit. Aim for decent coverage on the important logic you don’t need 100%, but 0% looks bad to users.</p><h3>Step 5: README, CHANGELOG, LICENSE</h3><p>This is where a lot of packages fall short, but it really shows maturity.</p><ul><li><a href="http://readme.md/"><strong>README.md</strong></a>: I wrote a friendly one with</li><li>Quick “why this package” intro</li><li>Installation (just the pub.dev line)</li><li>Simple usage example with copy-paste code</li><li>Screenshot or GIF if possible (huge help)</li><li>Contribution notes</li><li><a href="http://changelog.md/"><strong>CHANGELOG.md</strong></a>: Even for v0.1.0 I started it. Later it’s gold for users.</li><li><strong>LICENSE</strong>: MIT is fine for most open-source stuff. Don’t skip this pub.dev requires it.</li></ul><h3>Step 6: Dry-run</h3><p>Before going live I always do:</p><pre>dart pub publish --dry-run</pre><p>It catches formatting issues, missing files, bad pubspec entries, etc.</p><p>Now if you want to publish, hit this when everything is green:</p><pre>dart pub publish</pre><p>First publish asks you to log in with your Google account. After that it’s smooth.</p><p>A few minutes later my package was live on <a href="https://pub.dev/packages/my_cool_widget">https://pub.dev/packages/my_cool_widget</a> 🎉</p><h3>What I learned (the real takeaways)</h3><ul><li>Start small: solve your own pain first</li><li>Keep the API dead simple: fewer parameters = happier users</li><li>Tests + good README = way more stars/forks</li><li>Use src/ pattern and clean exports: looks professional</li><li>Do the dry-run every time: saved me from embarrassing v0.1.1 fixes</li></ul><p>If you’ve got some code you keep copying, try turning it into a package. It forces you to write better code, and it’s satisfying to see other people use something you built.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86399af8310f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tired of Manually Sending APKs?]]></title>
            <link>https://moreldenzel.medium.com/tired-of-manually-sending-apks-574797b41594?source=rss-2e69e67ee71d------2</link>
            <guid isPermaLink="false">https://medium.com/p/574797b41594</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[apk]]></category>
            <category><![CDATA[firebase-app-distribution]]></category>
            <dc:creator><![CDATA[Morel Denzel]]></dc:creator>
            <pubDate>Sun, 25 Jan 2026 21:18:56 GMT</pubDate>
            <atom:updated>2026-01-25T21:18:56.399Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NhHaQ6wHRMQbY-o2dfDG2Q.png" /></figure><h3>Tired of Manually Sending APKs? Here’s My Simple Flutter CI/CD Pipeline with GitHub Actions + Firebase</h3><p>Ever built a killer Flutter app, only to spend hours manually building and emailing APKs to your team? Yeah, me too. That’s where CI/CD comes in, it stands for Continuous Integration and Continuous Delivery, which basically means your code gets tested and built automatically, and then shared easily. In this post, I’ll walk you through setting up a simple pipeline using GitHub Actions for the automation part and Firebase App Distribution to share your Android APK with your team. We’ll focus on building the APK, sharing it among colleagues, and a few extra tips to make things smoother.</p><p>I’ve used this setup on a few projects, and it saves tons of time. No more manually emailing APKs or dealing with build errors late at night. Let’s dive in step by step. I’ll keep it straightforward assume you have a basic Flutter project ready.</p><h3>What You’ll Need Before Starting</h3><p>To follow along, make sure you have:</p><ul><li>A Flutter app in a GitHub repo. (If not, create one with <strong>flutter create my_app</strong> and push it to GitHub.)</li><li>A Firebase account. Head to <a href="https://console.firebase.google.com/">console.firebase.google.com</a> and create a new project if you don’t have one.</li><li>Firebase CLI installed. Run <strong>npm install -g firebase-tools</strong> in your terminal.</li><li>Android setup in your Flutter project (like having an <strong>android/app/build.gradle</strong> file ready).</li><li>A few colleagues’ emails for testing they’ll need to accept invites from Firebase.</li></ul><p>That’s it! No fancy tools required.</p><h3>Step 1: Set Up Firebase for Your App</h3><p>First, link your Flutter app to Firebase. This lets you use App Distribution.</p><ol><li>Go to your Firebase console and add an Android app to your project. You’ll need your app’s package name (find it in <strong>android/app/build.gradle</strong> under <strong>applicationId</strong>).</li><li>Download the <strong>google-services.json</strong> file and drop it into your Flutter project’s <strong>android/app</strong> folder.</li><li>In Firebase, enable App Distribution. It’s under the “Release &amp; Monitor” section.</li><li>Create a tester group. Click “App Distribution” &gt; “Testers &amp; Groups” &gt; “Add group.” Name it something like “team-testers” and add your colleagues’ emails. They’ll get an invite to set up their devices.</li></ol><p>Now, generate a Firebase token for CI/CD. On your local machine, run:</p><pre>firebase login:ci</pre><p>This gives you a long token. Copy it, we’ll use it soon.</p><h3>Step 2: Add Secrets to GitHub</h3><p>We don’t want sensitive info like your Firebase token in your code. GitHub has a safe spot for that.</p><ol><li>Go to your repo on GitHub &gt; Settings &gt; Secrets and variables &gt; Actions.</li><li>Click “New repository secret.”</li><li>Name it <strong>FIREBASE_TOKEN</strong> and paste the token you generated.</li><li>Add another secret called <strong>FIREBASE_APP_ID</strong>. You can find this in Firebase console &gt; Project settings &gt; Your apps. It’s something like <strong>1:1234567890:android:abcdef123456.</strong></li></ol><p>This keeps everything secure, no leaks!</p><h3>Step 3: Create Your GitHub Workflow</h3><p>This is the heart of the automation. We’ll make a file that tells GitHub what to do when you push code.</p><p>In your repo, create a folder .<strong>github/workflows</strong> and add a file called <strong>flutter-ci.yml</strong>. Paste this in:</p><pre>name: Flutter CI/CD<br><br>on:<br>  push:<br>    branches: [ main ]<br><br>jobs:<br>  build-and-distribute:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Checkout Code<br>        uses: actions/checkout@v4<br><br>      - name: Set up Flutter<br>        uses: subosito/flutter-action@v2<br>        with:<br>          flutter-version: &#39;3.19.0&#39;  # Change to your Flutter version if needed<br><br>      - name: Install Dependencies<br>        run: flutter pub get<br><br>      - name: Run Tests<br>        run: flutter test  # This runs your unit tests – add some if you haven&#39;t!<br><br>      - name: Build APK<br>        run: flutter build apk --release<br><br>      - name: Install Firebase CLI<br>        run: npm install -g firebase-tools<br><br>      - name: Distribute to Firebase<br>        env:<br>          FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}<br>        run: |<br>          firebase appdistribution:distribute build/app/outputs/flutter-apk/app-release.apk \<br>            --app ${{ secrets.FIREBASE_APP_ID }} \<br>            --groups &quot;team-testers&quot; \<br>            --release-notes &quot;New build from main branch!&quot;</pre><p>What’s happening here?</p><ul><li>On push to <strong>main</strong>, it checks out your code.</li><li>Sets up Flutter.</li><li>Gets dependencies.</li><li>Runs tests (to catch bugs early).</li><li>Builds the release APK.</li><li>Installs Firebase tools.</li><li>Uploads the APK to Firebase and shares it with your tester group.</li></ul><p>Push this file to your repo, and watch the magic in GitHub &gt; Actions tab. If it works, your team gets an email with a download link.</p><h3>Step 4: Building the APK Automatically</h3><p>The workflow above handles this. Every push to main builds a fresh APK. If you want to build for other flavors (like dev or prod), add<strong> — flavor dev</strong> to the build command and set up flavors in your <strong>pubspec.yaml.</strong></p><p>Pro tip: Add caching to speed things up. Update your YAML with:</p><pre>- name: Cache Flutter Dependencies<br>  uses: actions/cache@v3<br>  with:<br>    path: ~/.pub-cache<br>    key: ${{ runner.os }}-pub-${{ hashFiles(&#39;**/pubspec.lock&#39;) }}</pre><p>This reuses downloaded packages, cutting build time in half.</p><h3>Step 5: Sharing Among Colleagues</h3><p>Firebase makes this easy. Once distributed:</p><ul><li>Testers get an email invite if they’re new.</li><li>They download the app via a web link (Firebase handles the install).</li><li>You can add release notes in the CLI command for context, like “Fixed that login bug!”</li></ul><p>In the Firebase console, you can see who downloaded it and any feedback they submit in-app.</p><p>If you want more control, create multiple groups — one for QA, one for stakeholders.</p><h3>Important Note: If You’re Working in a Company or Team Project</h3><p>In my own experience (and I’ve been there!), if your Flutter app lives in a company Firebase project, things can feel a bit different.</p><p>A lot of companies lock down their Firebase/Google Cloud projects tightly for security reasons. So when I first tried setting this up, I had to ping the admin/devops person and ask for Project Manager (or Owner/Editor) access just to do the initial setup steps, like linking the app, enabling App Distribution, creating tester groups, or generating a token/service account.</p><p>But here’s the good news: <strong>you don’t actually need those high-level permissions forever</strong> (and definitely not in your CI/CD pipeline).</p><ul><li>The <strong>personal token</strong> from firebase login:ci works great for quick tests on your local machine… but it’s tied to <em>your</em> account. If you leave the company or your access changes, it breaks. Plus, it’s not the safest for long-term automation.</li><li>For real CI/CD (like in GitHub Actions), the better and more secure way is to use a <strong>Google Cloud service account</strong> with the minimal permissions needed.</li></ul><p>The only role your service account really needs for uploading builds is Firebase App Distribution Admin (roles/firebaseappdistro.admin). This lets it create releases, add testers, etc… without giving it full control over the whole Firebase project.</p><h4>Quick Steps for Company Mode (Ask Your Admin Once)</h4><ol><li>Ask your company Firebase/Google Cloud admin to:</li></ol><ul><li>Create a new <strong>service account</strong> in the Google Cloud console for your project (under IAM &amp; Admin &gt; Service Accounts).</li><li>Give that service account the <strong>Firebase App Distribution Admin</strong> role.</li><li>Download the JSON key file for that service account.</li></ul><p>2. In your GitHub repo → Settings → Secrets and variables → Actions:</p><ul><li>Add a new secret called <strong>FIREBASE_SERVICE_ACCOUNT_JSON </strong>and paste the entire JSON key content there.</li></ul><p>3. Update your workflow <strong>YAML </strong>to use the action that supports service accounts (instead of the old token method). A popular one is the community action:</p><pre>- name: Distribute APK to Firebase<br>  uses: wzieba/Firebase-Distribution-Github-Action@v1<br>  with:<br>    appId: ${{ secrets.FIREBASE_APP_ID }}<br>    serviceCredentialsFileContent: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_JSON }}<br>    groups: team-testers<br>    file: build/app/outputs/flutter-apk/app-release.apk<br>    releaseNotes: &quot;Automated build from ${{ github.sha }} – check it out!&quot;</pre><p>This is way more secure, doesn’t rely on anyone’s personal login, and works even if permissions change later.</p><p>Bottom line: If it’s a personal project, stick with the simple token method it’s fast. But in a company setup, go the service account route once the admin helps you set it up. After that initial ask, you won’t need Project Manager access anymore for everyday builds and sharing.</p><p>It took me a bit of back-and-forth the first time, but now it’s smooth sailing. Your team gets fresh APKs without anyone having to manually build or upload anything. Win-win! 🚀</p><p>If your company already has a shared service account for CI/CD, just ask to use that one even better.</p><p>Happy automating, and feel free to tweak this based on your exact setup! 😄</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=574797b41594" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with Flutter on iOS: What Android Developers Should Know]]></title>
            <link>https://moreldenzel.medium.com/getting-started-with-flutter-on-ios-what-android-developers-should-know-9ff8c41d52e0?source=rss-2e69e67ee71d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ff8c41d52e0</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Morel Denzel]]></dc:creator>
            <pubDate>Sat, 17 Jan 2026 19:46:32 GMT</pubDate>
            <atom:updated>2026-01-17T19:46:32.762Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sCaMBk1VcjpI6euXY0CntA.png" /></figure><p>If you’re coming from Android and Flutter, building your first iOS app can feel confusing at first. Flutter promises “write once, run everywhere”, but in reality, <strong>iOS comes with its own rules, tools, and constraints,</strong> mainly because Apple’s ecosystem is much stricter than Android’s.</p><p>I went through this transition myself, and in this article, I’ll walk you through the key things you must understand before building Flutter apps for iOS, especially if you’re already comfortable with Flutter on Android.</p><p>This is not a deployment guide only, it’s a mental model for how iOS works in the Flutter world.</p><h3>1. Apple Developer Account (Unlike Android, This Is Mandatory)</h3><p>On Android, you can:</p><ul><li>Build an APK</li><li>Install it on any phone</li><li>Share it freely</li></ul><p>On iOS, things are different.</p><p>To run your Flutter app on a <strong>real iPhone</strong> or publish it on the App Store, you <strong>must</strong> have an Apple Developer Account.</p><ul><li>Cost: <strong>$99/year</strong></li><li>Without it:</li><li>You can only run your app on the <strong>iOS simulator</strong></li><li>You cannot install the app on a physical iPhone</li></ul><p>👉 <strong>Key difference from Android</strong>:</p><p>Android allows sideloading freely. Apple does not.</p><h3>2. macOS &amp; Xcode Are Not Optional</h3><p>You can build Android apps on Windows or Linux.</p><p>For iOS, <strong>macOS is required</strong> no exceptions.</p><p>You need:</p><ul><li>A Mac</li><li>Xcode (latest stable version recommended)</li></ul><p>Flutter uses Xcode internally to:</p><ul><li>Compile iOS code</li><li>Manage signing</li><li>Handle native plugins</li></ul><p>Even if you never touch Swift or Objective-C, <strong>Xcode is always involved</strong> behind the scenes.</p><h3>3. Code Signing, Certificates &amp; Provisioning (The Biggest Shock for Android Devs)</h3><p>Android signing is simple:</p><ul><li>You generate a keystore</li><li>You’re done</li></ul><p>iOS signing is more complex.</p><p>Apple requires:</p><ul><li><strong>Development Certificate</strong> → for testing on your iPhone</li><li><strong>Distribution Certificate</strong> → for App Store release</li><li><strong>Provisioning Profile</strong> → links:</li><li>App ID</li><li>Certificates</li><li>Devices</li></ul><p>Flutter helps a lot when you run:</p><pre>flutter build ios</pre><p>…but sooner or later, you’ll need to open <strong>Xcode</strong> and understand what’s happening — especially when something breaks.</p><p>👉 <strong>Reality check</strong>:</p><p>If iOS signing scares you at first, you’re not alone. Every iOS developer goes through this phase.</p><h3>4. iOS Version Compatibility (Stricter Than Android)</h3><p>In Android, you usually define:</p><ul><li>minSdkVersion</li><li>targetSdkVersion</li></ul><p>In iOS, you define:</p><ul><li>A <strong>minimum iOS version</strong> in Xcode or Podfile</li></ul><p>Some Flutter plugins require:</p><ul><li>iOS 11+</li><li>iOS 12+</li><li>Or higher</li></ul><p>If your minimum version is too low:</p><ul><li>Build fails</li><li>Pods won’t install</li></ul><p>If it’s too high:</p><ul><li>Older iPhones won’t support your app</li></ul><p>👉 Always check plugin requirements before adding them.</p><h3>5. CocoaPods: The iOS Equivalent of Gradle Dependencies</h3><p>On Android, Flutter plugins integrate through <strong>Gradle</strong>.</p><p>On iOS, they use <strong>CocoaPods</strong>.</p><p>Whenever you add or update a Flutter dependency that has native iOS code, you should run:</p><pre>cd ios<br>pod install</pre><p>Things to remember:</p><ul><li>CocoaPods must be installed correctly</li><li>Podfile.lock should stay in sync with your Flutter dependencies</li><li>Pod issues are one of the most common iOS build errors</li></ul><p>👉 If Android errors feel verbose, iOS Pod errors feel… cryptic.</p><h3>6. Permissions Are Mandatory (Or Your App Will Crash)</h3><p>Android:</p><ul><li>You can sometimes forget a permission</li><li>The app still launches</li></ul><p>iOS:</p><ul><li>Forget a permission → <strong>crash or App Store rejection</strong></li></ul><p>Every permission must be declared in Info.plist.</p><p>Example:</p><pre>&lt;key&gt;NSCameraUsageDescription&lt;/key&gt;<br>&lt;string&gt;This app needs access to the camera to take photos&lt;/string&gt;<br>&lt;key&gt;NSLocationWhenInUseUsageDescription&lt;/key&gt;<br>&lt;string&gt;We need your location to show nearby stores&lt;/string&gt;</pre><p>No description = no approval.</p><p>👉 Apple is very strict about user privacy.</p><h3>7. Simulator vs Real Device (Huge Difference on iOS)</h3><p>iOS simulators are good, but <strong>not enough</strong>.</p><p>Some features <strong>do not behave the same</strong>:</p><ul><li>Push notifications</li><li>Camera</li><li>GPS</li><li>Performance</li></ul><p>Testing on a real iPhone is essential.</p><p>To do this:</p><ul><li>Connect your iPhone via USB</li><li>Select it in Xcode or run:</li></ul><pre>flutter run</pre><p>👉 Unlike Android emulators, iOS simulators are limited by design.</p><h3>8. App Store Guidelines Matter (Even for Flutter Apps)</h3><p>Your app can work perfectly and still get rejected.</p><p>Common reasons:</p><ul><li>Missing privacy explanations</li><li>App crashes</li><li>Poor UI that violates Apple’s Human Interface Guidelines</li><li>Using restricted APIs</li></ul><p>Flutter does not protect you from these rules.</p><p>At the end of the day, <strong>Apple reviews your app as an iOS app</strong>, not a Flutter app.</p><h3>9. Build Modes: Don’t Skip Release Testing</h3><p>Flutter offers three modes:</p><ul><li><strong>Debug</strong> → development</li><li><strong>Profile</strong> → performance testing</li><li><strong>Release</strong> → production</li></ul><p>Commands:</p><pre>flutter run# Debug<br>flutter build ios# Release</pre><p>👉 Always test the <strong>Release build</strong> before submitting to TestFlight or the App Store. Some bugs only appear in release mode.</p><h3>10. TestFlight: iOS Beta Testing (Mandatory)</h3><p>On Android, you can:</p><ul><li>Send an APK</li><li>Use internal testing easily</li></ul><p>On iOS:</p><ul><li><strong>TestFlight is mandatory</strong></li></ul><p>Workflow:</p><ol><li>Upload your app (.ipa) via Xcode</li><li>Distribute it through TestFlight</li><li>Invite testers</li><li>Collect feedback</li></ol><p>There’s no “send the app file” shortcut.</p><h3>Final Thoughts</h3><p>Flutter makes cross-platform development easier, but <strong>iOS still plays by Apple’s rules</strong>.</p><p>If you’re coming from Android:</p><ul><li>Expect more restrictions</li><li>Expect more configuration</li><li>Expect more discipline</li></ul><p>But once you understand the ecosystem, iOS becomes predictable and stable.</p><h3>If you’re just starting, focus on:</h3><ul><li>Installing Xcode &amp; CocoaPods</li><li>Running Flutter on the iOS simulator</li><li>Testing on your own iPhone</li><li>Declaring permissions correctly</li></ul><p>Once these foundations are solid, the rest becomes much smoother.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ff8c41d52e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Development: Building Third-Party Libraries (Packages & Plugins)]]></title>
            <link>https://moreldenzel.medium.com/flutter-development-building-third-party-libraries-packages-plugins-3d4ae8054571?source=rss-2e69e67ee71d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d4ae8054571</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[plugins]]></category>
            <category><![CDATA[package]]></category>
            <dc:creator><![CDATA[Morel Denzel]]></dc:creator>
            <pubDate>Sat, 15 Mar 2025 13:44:55 GMT</pubDate>
            <atom:updated>2025-03-15T13:44:55.466Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*babsuoDkJk7vWezJke0p9Q.png" /></figure><p>As I continued to expand my Flutter skills, I realized that one of the most exciting aspects of development was building third-party libraries, packages and plugins. Not only does this allow you to extend Flutter’s capabilities, but it’s also a great way to contribute to the growing Flutter ecosystem.</p><p>I’ll walk you through the journey of creating <strong>Flutter packages</strong> and <strong>plugins</strong>, explaining the key differences between them. I’ll also show you the steps on how to get started with each type of library. This journey was a fun challenge, and I hope it helps you get started with your own development of Flutter libraries!</p><h4>The Difference Between Flutter Packages and Plugins</h4><p>Before diving into how to create them, let’s quickly establish the difference between <strong>packages</strong> and <strong>plugins</strong> in Flutter:</p><p><strong>Packages</strong>: A package is a simple collection of Dart code that can be used across multiple Flutter projects. It doesn’t require any platform-specific code (like iOS/Android). You can think of it as a pure Dart library that adds functionality to your app.</p><p><strong>Plugins</strong>: A plugin, on the other hand, is a package that includes both Dart code <em>and</em> platform-specific code (for iOS and Android). Plugins are used when you need to interact with native device features like the camera, GPS, or sensors. They require additional setup to link the Dart code with the platform-specific native code.</p><blockquote>In short: <strong>Packages = Dart only. Plugins = Dart + native platform code (iOS/Android).</strong></blockquote><h4>Creating a Flutter Package</h4><p>When I decided to create my first <strong>Flutter package</strong>, I wanted to build something simple and reusable. Here’s how you can create a package step by step:</p><h4>1. Set Up the Package Structure</h4><p>To start, you’ll want to create a new package. You can do this using the flutter create command. The key here is to specify --template=package to create a pure Dart package.</p><pre>flutter create --template=package my_flutter_package</pre><p>This command will generate a folder structure like this:</p><pre>my_flutter_package/<br>│<br>├── lib/<br>│   └── my_flutter_package.dart<br>│<br>├── pubspec.yaml<br>└── README.md</pre><h4>2. Write Your Package Code</h4><p>Once your package is created, you can start adding functionality. For example, let’s say I want to create a simple utility package that calculates the sum of two numbers. Here’s how the Dart code might look:</p><pre>// lib/my_flutter_package.dart<br><br>library my_flutter_package;<br><br>int sum(int a, int b) {<br>  return a + b;<br>}</pre><h4>3. Testing Your Package</h4><p>To test the package, you can create a <strong>Flutter app</strong> (or use an existing one) and add your package as a dependency in the pubspec.yaml file:</p><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br>  my_flutter_package:<br>    path: ../my_flutter_package  # Local path to the package</pre><p>Then, in your Flutter app, you can import and use the package:</p><pre>import &#39;package:my_flutter_package/my_flutter_package.dart&#39;;<br><br>void main() {<br>  print(sum(3, 5)); // Outputs: 8<br>}</pre><p>That’s it! You’ve created a basic <strong>Flutter package</strong>. The process is straightforward, and you don’t need to worry about platform-specific code.</p><h4>Creating a Flutter Plugin</h4><p>Next up, I wanted to try my hand at building a <strong>Flutter plugin</strong>. For this, I needed to work with both Dart and platform-specific code. Let’s go through the steps of setting up a plugin.</p><h4>1. Set Up the Plugin Structure</h4><p>Just like with the package, you’ll start by creating a plugin using flutter create. The key here is to specify --template=plugin:</p><pre>flutter create --template=plugin my_flutter_plugin</pre><p>This creates a structure that includes both Dart code and platform-specific code:</p><pre>my_flutter_plugin/<br>│<br>├── lib/<br>│   └── my_flutter_plugin.dart  # Dart code<br>│<br>├── android/<br>│   └── src/main/java/com/example/my_flutter_plugin/MyFlutterPlugin.java<br>│<br>├── ios/<br>│   └── Classes/MyFlutterPlugin.m<br>│<br>├── pubspec.yaml<br>└── README.md</pre><h4>2. Write Your Plugin Code</h4><p>In a plugin, the Dart code acts as an interface to the platform-specific code. Let’s say I want my plugin to access the device’s battery level. I’d start by writing the Dart interface:</p><pre>// lib/my_flutter_plugin.dart<br><br>import &#39;dart:async&#39;;<br>import &#39;package:flutter/services.dart&#39;;<br><br>class MyFlutterPlugin {<br>  static const MethodChannel _channel = MethodChannel(&#39;com.example.my_flutter_plugin&#39;);<br><br>  static Future&lt;int&gt; getBatteryLevel() async {<br>    final int batteryLevel = await _channel.invokeMethod(&#39;getBatteryLevel&#39;);<br>    return batteryLevel;<br>  }<br>}</pre><h4>3. Write the Native Code</h4><p>Next, I’d write the platform-specific code for <strong>Android</strong> and <strong>iOS</strong>.</p><p>Android (Java)</p><pre>// android/src/main/java/com/example/my_flutter_plugin/MyFlutterPlugin.java<br><br>package com.example.my_flutter_plugin;<br><br>import android.content.Context;<br>import android.os.BatteryManager;<br><br>public class MyFlutterPlugin implements MethodCallHandler {<br>  private final Context context;<br><br>  MyFlutterPlugin(Context context) {<br>    this.context = context;<br>  }<br><br>  @Override<br>  public void onMethodCall(MethodCall call, MethodChannel.Result result) {<br>    if (call.method.equals(&quot;getBatteryLevel&quot;)) {<br>      int batteryLevel = getBatteryLevel();<br>      result.success(batteryLevel);<br>    } else {<br>      result.notImplemented();<br>    }<br>  }<br><br>  private int getBatteryLevel() {<br>    BatteryManager batteryManager = (BatteryManager) context.getSystemService(Context.BATTERY_SERVICE);<br>    return batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);<br>  }<br>}</pre><p>iOS (Objective-C)</p><pre>// ios/Classes/MyFlutterPlugin.m<br><br>#import &quot;MyFlutterPlugin.h&quot;<br>#import &lt;Flutter/Flutter.h&gt;<br><br>@implementation MyFlutterPlugin<br><br>- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {<br>  if ([@&quot;getBatteryLevel&quot; isEqualToString:call.method]) {<br>    int batteryLevel = [self getBatteryLevel];<br>    result(@(batteryLevel));<br>  } else {<br>    result(FlutterMethodNotImplemented);<br>  }<br>}<br><br>- (int)getBatteryLevel {<br>  UIDevice *device = [UIDevice currentDevice];<br>  [device setBatteryMonitoringEnabled:YES];<br>  return (int)(device.batteryLevel * 100);<br>}<br><br>@end</pre><h4>4. Testing Your Plugin</h4><p>Once the native code is set up, you can test your plugin in a Flutter app, just like we did with the package. The only difference is you need to call the platform-specific code using method channels:</p><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br>  my_flutter_plugin:<br>    path: ../my_flutter_plugin  # Local path to the plugin</pre><p>And in your Flutter app, you can call the plugin like this:</p><pre>import &#39;package:my_flutter_plugin/my_flutter_plugin.dart&#39;;<br><br>void main() async {<br>  int batteryLevel = await MyFlutterPlugin.getBatteryLevel();<br>  print(&#39;Battery level: $batteryLevel%&#39;);<br>}</pre><p>With both, you can add so much value to the Flutter ecosystem and create reusable components that others can use in their own projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d4ae8054571" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Large Language Models vs. Reinforcement Learning: What’s the Deal?]]></title>
            <link>https://moreldenzel.medium.com/large-language-models-vs-reinforcement-learning-whats-the-deal-5a70fff2c3a3?source=rss-2e69e67ee71d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a70fff2c3a3</guid>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[model]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[aritificial-intelligence]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <dc:creator><![CDATA[Morel Denzel]]></dc:creator>
            <pubDate>Wed, 19 Feb 2025 18:57:32 GMT</pubDate>
            <atom:updated>2025-02-19T18:57:32.156Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NGP_unHg32ElV3xrAbifmw.png" /></figure><p>If you’ve been anywhere near AI and machine learning discussions, you’ve probably heard of Large Language Models (LLMs) and Reinforcement Learning (RL). But if you’re wondering how they compare or when to use each, let’s break it down:</p><h3>What Are LLMs and RL?</h3><h3>Large Language Models (LLMs)</h3><p>LLMs, like OpenAI’s ChatGPT, Google’s Gemini, or Meta’s LLaMA, are basically giant brain-like systems trained on massive amounts of text. They predict what word comes next in a sentence and can generate human-like responses. Their power comes from deep learning, particularly Transformer architectures, which allow them to handle crazy amounts of data and learn language patterns like a pro.</p><blockquote><strong>Think of it like:</strong> A super-intelligent parrot that doesn’t just mimic words but actually understands context and meaning (most of the time).</blockquote><h3>Reinforcement Learning (RL)</h3><p>Reinforcement Learning (RL) is all about learning by doing. It trains models to make decisions by interacting with an environment and learning from rewards and punishments. RL is widely applied in robotics, game AI, and optimizing business processes. Advanced AIs like Deepseek and Wayve.ai leverage RL to enhance decision-making in complex tasks, from autonomous driving to problem-solving.</p><blockquote><strong>Think of it like:</strong> Training a puppy — it learns tricks by getting treats when it does something right and no rewards (or mild discouragement) when it does something wrong.</blockquote><h3>Real-Life Use Cases</h3><h3>📚 Chatbots &amp; Text Analysis → LLMs</h3><p>If you’re building a chatbot for customer support, sentiment analysis, or anything involving human-like text processing, LLMs are the go-to. They can generate responses, summarize documents, and even translate languages effortlessly.</p><blockquote><strong>Example:</strong> A chatbot for a tech company that helps users troubleshoot software issues.</blockquote><h3>🎮 Robotics, Gaming, and Automation → RL</h3><p>If you’re developing a self-learning system that needs to make real-time decisions and improve over time, RL is your best bet. It’s often used in robotics, game AI, and even financial trading.</p><blockquote><strong>Example:</strong> A self-driving car using RL to navigate city traffic and improve its driving skills over time.</blockquote><h3>To wrap it up</h3><p>Use<strong> LLMs</strong> if your task involves language, conversation, or unstructured text and <strong>RL</strong> if you need a model that learns from interactions and improves over time.</p><p>Sometimes, you might even combine both! For example, using RL to fine-tune an LLM for better conversational responses.</p><p>At the end of the day, they’re both powerful but serve different purposes.</p><blockquote>Think of it like comparing a novelist (LLM) to an athlete (RL) — both are great, but it depends on what skills you need.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a70fff2c3a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Local Notifications in Flutter with flutter_local_notifications]]></title>
            <link>https://moreldenzel.medium.com/mastering-local-notifications-in-flutter-with-flutter-local-notifications-94d09c8d665f?source=rss-2e69e67ee71d------2</link>
            <guid isPermaLink="false">https://medium.com/p/94d09c8d665f</guid>
            <category><![CDATA[singleton]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[local-notifications]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Morel Denzel]]></dc:creator>
            <pubDate>Sun, 02 Feb 2025 20:08:16 GMT</pubDate>
            <atom:updated>2025-02-02T20:08:16.632Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3DhcaEyttz2yW1FNAvnNXA.png" /></figure><p>Ever wondered how apps remind you of important tasks even when they’re closed? That’s the power of local notifications! In this guide, I’ll show you how to implement them in your Flutter app using <strong>flutter_local_notifications </strong>— step-by-step.</p><p>Highlight the benefits:</p><ul><li>Engaging users with reminders</li><li>Boosting app retention</li><li>Works offline</li></ul><h3>Step 1: Setting Up the Project:</h3><pre>dependencies:<br>  flutter_local_notifications: ^12.0.4</pre><p><em>Run </em><em>flutter pub get to install the package.</em></p><h3>Step 2: Android Permissions:</h3><p>To allow your app to display notifications, especially on <strong>Android 13+</strong>, you need to add the necessary permissions in the AndroidManifest.xml file.</p><p>File Path:</p><pre>android/app/src/main/AndroidManifest.xml</pre><pre>&lt;uses-permission android:name=&quot;android.permission.POST_NOTIFICATIONS&quot; /&gt;</pre><h3>Step 3: Implementing the Notification Service:</h3><p>First, we have Class Definition and Singleton Pattern</p><p><em>Just in case, a </em><strong><em>Singleton Pattern</em></strong><em> is a design pattern that ensures a class has </em><strong><em>only one instance</em></strong><em> throughout the app and provides a global access point to that instance.</em></p><pre>class NotificationService {<br>  static final NotificationService _notificationService = NotificationService._internal();<br>  final FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();<br>  <br>  factory NotificationService() =&gt; _notificationService;<br>  <br>  NotificationService._internal();<br>}</pre><p>Next, we Initializing the Notification Plugin</p><pre>Future&lt;void&gt; initialize() async {<br>  const AndroidInitializationSettings androidSettings = AndroidInitializationSettings(&#39;@mipmap/ic_launcher&#39;);<br>const InitializationSettings initSettings = InitializationSettings(android: androidSettings);<br>  await _flutterLocalNotificationsPlugin.initialize(initSettings);<br>}</pre><p><strong>initialize()</strong>: Prepares the notification plugin to work in your app. This should be called in main() before runApp()</p><p><strong>Key Components:</strong></p><ul><li><strong>AndroidInitializationSettings</strong>:</li><li>Specifies the default app icon (@mipmap/ic_launcher) for notifications.</li><li>You can replace it with a custom icon if needed.</li><li><strong>InitializationSettings</strong>:</li><li>Combines platform-specific settings. Here, it’s Android-specific, but for iOS, you’d add IOSInitializationSettings.</li><li><strong>_flutterLocalNotificationsPlugin.initialize()</strong>:</li><li>Activates the plugin with the provided settings.</li><li>Without this, notifications won’t work even if other methods are correctly implemented.</li></ul><p>Then, we display a Notification</p><pre>Future&lt;void&gt; showNotification({required int id, required String title, required String body}) async {<br>  const AndroidNotificationDetails androidDetails = AndroidNotificationDetails(<br>    &#39;channel_id&#39;, <br>    &#39;channel_name&#39;,<br>    channelDescription: &#39;channel_description&#39;,<br>    importance: Importance.max,<br>    priority: Priority.high,<br>  );<br>const NotificationDetails platformDetails = NotificationDetails(android: androidDetails);<br>  await _flutterLocalNotificationsPlugin.show(id, title, body, platformDetails);<br>}</pre><p><strong>AndroidNotificationDetails here:</strong></p><ul><li>Defines how the notification looks and behaves on Android.</li><li><strong>channel_id &amp; </strong><strong>channel_name</strong>:</li><li>Android requires notifications to be part of a channel (introduced in Android 8.0).</li><li>Channels help users control notification settings (like sound/vibration) for different categories.</li><li><strong>importance: Importance.max</strong>: Ensures the notification grabs attention (high priority, heads-up style).</li><li><strong>priority: Priority.high</strong>: Determines how the notification is shown when the app is in the foreground.</li></ul><p>As result, we have this</p><pre>class NotificationService {<br>  static final NotificationService _notificationService = NotificationService._internal();<br>  final FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();<br>  <br>  factory NotificationService() =&gt; _notificationService;<br>  NotificationService._internal();<br>  <br>  Future&lt;void&gt; initialize() async {<br>    const AndroidInitializationSettings androidSettings = AndroidInitializationSettings(&#39;@mipmap/ic_launcher&#39;);<br>    const InitializationSettings initSettings = InitializationSettings(android: androidSettings);<br>    await _flutterLocalNotificationsPlugin.initialize(initSettings);<br>  }<br>Future&lt;void&gt; showNotification({required int id, required String title, required String body}) async {<br>    const AndroidNotificationDetails androidDetails = AndroidNotificationDetails(<br>      &#39;channel_id&#39;, &#39;channel_name&#39;,<br>      channelDescription: &#39;channel_description&#39;,<br>      importance: Importance.max,<br>      priority: Priority.high,<br>    );<br>    const NotificationDetails platformDetails = NotificationDetails(android: androidDetails);<br>    await _flutterLocalNotificationsPlugin.show(id, title, body, platformDetails);<br>  }<br>}</pre><h3>Requesting Permissions (iOS):</h3><pre>dart<br>CopyEdit<br>if (Platform.isIOS) {<br>  await _flutterLocalNotificationsPlugin<br>    .resolvePlatformSpecificImplementation&lt;IOSFlutterLocalNotificationsPlugin&gt;()<br>    ?.requestPermissions(alert: true, badge: true, sound: true);<br>}</pre><p><em>“iOS requires explicit permission for notifications.”</em></p><h3>Step 4: Initializing the Singleton Pattern in the Root App</h3><p>To make sure the NotificationService works properly, you need to <strong>initialize it</strong> in your main.dart file. This ensures the notification system is ready to handle any notification requests</p><pre>import &#39;notification_service.dart&#39;; // Import your service<br><br>void main() async {<br>  WidgetsFlutterBinding.ensureInitialized(); // Ensures proper binding before initialization<br>  await NotificationService().initialize();  // Initializes the singleton<br>  runApp(MyApp());<br>}<br>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      title: &#39;Local Notifications App&#39;,<br>      home: HomeScreen(),<br>    );<br>  }<br>}</pre><h3>Step5: Triggering Notifications</h3><p>Example button in HomeScreen:</p><pre>ElevatedButton(<br>  onPressed: () {<br>    NotificationService().showNotification(<br>      id: 0,<br>      title: &#39;Hello!&#39;,<br>      body: &#39;Your first local notification.&#39;,<br>    );<br>  },<br>  child: Text(&#39;Show Notification&#39;),<br>)</pre><h3>Step 6: Testing &amp; Debugging Tips:</h3><ul><li>Test on real devices (emulators may not show all notifications properly).</li><li>Check background behavior.</li><li>Use logs to debug if notifications don’t trigger.</li></ul><p><strong>Tried this tutorial?</strong> Share your thoughts, questions, or cool notification ideas in the comments below — I’d love to hear from you! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94d09c8d665f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handle Java Authentication with JWT and Maven]]></title>
            <link>https://moreldenzel.medium.com/handle-java-authentication-with-jwt-and-maven-01720d4d7944?source=rss-2e69e67ee71d------2</link>
            <guid isPermaLink="false">https://medium.com/p/01720d4d7944</guid>
            <category><![CDATA[maven]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[jwt-authentication]]></category>
            <dc:creator><![CDATA[Morel Denzel]]></dc:creator>
            <pubDate>Sat, 25 Jan 2025 09:28:51 GMT</pubDate>
            <atom:updated>2025-01-25T09:28:51.291Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Rz2VYw4Wmy7o76TNJpZSA.png" /></figure><p>Authentication is a fundamental aspect of application security. In this blog, we’ll explore how to implement authentication in a Java-based application using JSON Web Tokens (JWT) and Maven. We’ll walk through a simple project with sign-up, login, and middleware for token validation.</p><h3>Prerequisites</h3><ul><li><strong>Java 11+</strong></li><li><strong>Maven</strong></li><li>A basic understanding of REST APIs</li><li><strong>MySQL</strong> (or any other database) for storing user data</li><li><strong>App.js</strong>: The main entry point to start the server.</li></ul><h3>Step 1: Setting Up Maven Dependencies</h3><p>Add the following dependencies to your pom.xml file for working with JWT, JSON, and BCrypt for password hashing:</p><pre>&lt;dependencies&gt;<br>    &lt;!-- JWT for token generation and validation --&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;io.jsonwebtoken&lt;/groupId&gt;<br>        &lt;artifactId&gt;jjwt&lt;/artifactId&gt;<br>        &lt;version&gt;0.9.1&lt;/version&gt;<br>    &lt;/dependency&gt;<br><br>    &lt;!-- BCrypt for secure password hashing --&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.mindrot&lt;/groupId&gt;<br>        &lt;artifactId&gt;jbcrypt&lt;/artifactId&gt;<br>        &lt;version&gt;0.4&lt;/version&gt;<br>    &lt;/dependency&gt;<br><br>    &lt;!-- Jackson for JSON processing --&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;<br>        &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;<br>        &lt;version&gt;2.13.2&lt;/version&gt;<br>    &lt;/dependency&gt;<br><br>    &lt;!-- Jackson module for Java 8 Date/Time API --&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;com.fasterxml.jackson.datatype&lt;/groupId&gt;<br>        &lt;artifactId&gt;jackson-datatype-jsr310&lt;/artifactId&gt;<br>        &lt;version&gt;2.13.2&lt;/version&gt;<br>    &lt;/dependency&gt;<br><br>    &lt;!-- Servlet API for building web applications --&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;jakarta.servlet&lt;/groupId&gt;<br>        &lt;artifactId&gt;jakarta.servlet-api&lt;/artifactId&gt;<br>        &lt;version&gt;5.0.0&lt;/version&gt;<br>    &lt;/dependency&gt;<br><br>    &lt;!-- MySQL Connector for database interaction --&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;mysql&lt;/groupId&gt;<br>        &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;<br>        &lt;version&gt;8.0.33&lt;/version&gt;<br>    &lt;/dependency&gt;<br>&lt;/dependencies&gt;</pre><h3>Step 2: Database Setup</h3><p>Ensure you have a user table with the following structure:</p><pre>CREATE TABLE user (<br>    id INT AUTO_INCREMENT PRIMARY KEY,<br>    uid VARCHAR(255) NOT NULL,<br>    username VARCHAR(255) NOT NULL,<br>    email VARCHAR(255) NOT NULL UNIQUE,<br>    password VARCHAR(255) NOT NULL,<br>    dateof TIMESTAMP DEFAULT CURRENT_TIMESTAMP<br>);</pre><h3>Step 3: AuthModel</h3><p>The AuthModel class represents user data. It is used to map JSON requests into Java objects.</p><pre>package com.back;<br>import com.fasterxml.jackson.annotation.JsonIgnoreProperties;<br>@JsonIgnoreProperties(ignoreUnknown = true)<br>public class AuthModel {<br>    private String uid;<br>    private String username;<br>    private String email;<br>    private String password;<br>    // Getters and setters<br>}</pre><p>The @JsonIgnoreProperties annotation tells Jackson to ignore certain fields during JSON processing. It can skip unknown fields in incoming JSON (ignoreUnknown = true) or exclude specific fields from being serialized or deserialized. This helps prevent errors and manage irrelevant or sensitive data.</p><h3>Step 4: AuthController</h3><p>The AuthController class handles sign-up, login, and token generation.</p><h3>Key Features:</h3><ul><li><strong>BCrypt</strong> is used for password hashing.</li><li><strong>JWT</strong> generates tokens for authenticated users.</li><li>Uses JDBC for database interactions.</li></ul><pre>package com.back;<br><br>import java.io.IOException;<br>import java.sql.Connection;<br>import java.sql.PreparedStatement;<br>import java.sql.ResultSet;<br>import java.sql.SQLException;<br>import java.util.Map;<br>import java.util.HashMap;<br>import org.mindrot.jbcrypt.BCrypt;<br>import io.jsonwebtoken.Jwts;<br>import io.jsonwebtoken.SignatureAlgorithm;<br>import java.util.Date;<br>import java.util.Base64;<br>import com.fasterxml.jackson.databind.ObjectMapper;<br>import jakarta.servlet.http.HttpServlet;<br>import jakarta.servlet.http.HttpServletRequest;<br>import jakarta.servlet.http.HttpServletResponse;<br><br>public class AuthController extends HttpServlet {<br>    private static final String SECRET_KEY = Base64.getEncoder().encodeToString(&quot;your-secret-key&quot;.getBytes());<br>    private static final long EXPIRATION_TIME = 1000 * 60 * 60 * 24;<br><br>    private final Connection connection;<br>    private final ObjectMapper objectMapper = new ObjectMapper();<br><br>    public AuthController(Connection connection) {<br>        this.connection = connection;<br>    }<br><br>    @Override<br>    protected void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException {<br>        res.setHeader(&quot;Access-Control-Allow-Origin&quot;, &quot;&lt;http://localhost:5173&gt;&quot;);<br>        res.setHeader(&quot;Access-Control-Allow-Methods&quot;, &quot;POST, GET, PUT, OPTIONS, DELETE&quot;);<br>        res.setHeader(&quot;Access-Control-Allow-Headers&quot;, &quot;Content-Type, Authorization&quot;);<br>        res.setHeader(&quot;Access-Control-Max-Age&quot;, &quot;3600&quot;);<br>        res.setStatus(HttpServletResponse.SC_OK);<br>        <br>        res.setContentType(&quot;application/json&quot;);<br>    <br>        String pathInfo = req.getPathInfo();<br>        AuthModel auth = objectMapper.readValue(req.getReader(), AuthModel.class);<br><br>        if (&quot;/signup&quot;.equals(pathInfo)) {<br>            signUp(res, auth);<br>        } else if (&quot;/login&quot;.equals(pathInfo)) {<br>            login(res, auth);<br>        }<br>    }<br><br>    private void signUp(HttpServletResponse res, AuthModel auth) throws IOException {<br>        String hashedPassword = BCrypt.hashpw(auth.getPassword(), BCrypt.gensalt());<br>        String sql = &quot;INSERT INTO user (uid, username, email, password) VALUES (?, ?, ?, ?)&quot;;<br><br>        try (PreparedStatement stmt = connection.prepareStatement(sql)) {<br>            stmt.setString(2, auth.getUsername());<br>            stmt.setString(3, auth.getEmail());<br>            stmt.setString(4, hashedPassword);<br>            stmt.executeUpdate();<br><br>            res.setStatus(HttpServletResponse.SC_CREATED);<br>            res.getWriter().write(&quot;User signed up successfully&quot;);<br>        } catch (SQLException e) {<br>            res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);<br>            res.getWriter().write(&quot;Error: &quot; + e.getMessage());<br>        }<br>    }<br><br>    private void login(HttpServletResponse res, AuthModel auth) throws IOException {<br>        String sql = &quot;SELECT * FROM user WHERE email = ?&quot;;<br><br>        try (PreparedStatement stmt = connection.prepareStatement(sql)) {<br>            stmt.setString(1, auth.getEmail());<br>            ResultSet rs = stmt.executeQuery();<br><br>            if (rs.next() &amp;&amp; BCrypt.checkpw(auth.getPassword(), rs.getString(&quot;password&quot;))) {<br>                String token = Jwts.builder()<br>                    .setSubject(rs.getString(&quot;uid&quot;))<br>                    .setIssuer(&quot;your-app&quot;)<br>                    .setIssuedAt(new Date())<br>                    .setExpiration(new Date(System.currentTimeMillis() + EXPIRATION_TIME))<br>                    .signWith(SignatureAlgorithm.HS256, SECRET_KEY)<br>                    .compact();<br><br>                res.getWriter().write(&quot;JWT Token: &quot; + token);<br>            } else {<br>                res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);<br>                res.getWriter().write(&quot;Invalid credentials&quot;);<br>            }<br>        } catch (SQLException e) {<br>            res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);<br>            res.getWriter().write(&quot;Error: &quot; + e.getMessage());<br>        }<br>    }<br>}</pre><p>The <strong>headers here</strong> are used to configure Cross-Origin Resource Sharing (CORS) for the server. Access-Control-Allow-Origin allows requests from http://localhost:5173. Access-Control-Allow-Methods specifies permitted HTTP methods (e.g., POST, GET).</p><p>Access-Control-Allow-Headers defines allowed request headers, such as Content-Type and Authorization.</p><p>Access-Control-Max-Age indicates how long the CORS preflight response can be cached (3600 seconds).</p><p>Finally, res.setStatus(HttpServletResponse.SC_OK) sets the HTTP response status to 200 (OK), indicating a successful response.</p><p>These settings ensure secure communication between the server and the specified client origin.</p><h3>Step 5: JwtFilter (Middleware)</h3><p>The JwtFilter class validates JWT tokens in incoming requests.</p><pre>package com.back;<br><br>import io.jsonwebtoken.Claims;<br>import io.jsonwebtoken.Jwts;<br>import io.jsonwebtoken.SignatureException;<br><br>import jakarta.servlet.Filter;<br>import jakarta.servlet.FilterChain;<br>import jakarta.servlet.FilterConfig;<br>import jakarta.servlet.ServletException;<br>import jakarta.servlet.ServletRequest;<br>import jakarta.servlet.ServletResponse;<br>import jakarta.servlet.http.HttpServletRequest;<br>import jakarta.servlet.http.HttpServletResponse;<br><br>import java.util.Base64;<br>import java.util.Map;<br>import java.util.HashMap;<br>import com.fasterxml.jackson.databind.ObjectMapper;<br><br><br>import java.io.IOException;<br><br><br>public class JwtFilter implements Filter {<br><br>    public final ObjectMapper objectMapper = new ObjectMapper();<br><br>    private static final String SECRET_KEY = Base64.getEncoder().encodeToString(&quot;your-secret-key&quot;.getBytes());<br><br>    @Override<br>    public void init(FilterConfig filterConfig) throws ServletException {<br>        // Initialisation if required<br>    }<br><br>    @Override<br>    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {<br>        HttpServletRequest httpRequest = (HttpServletRequest) req;<br>        HttpServletResponse httpResponse = (HttpServletResponse) res;<br><br>        String authorizationHeader = httpRequest.getHeader(&quot;Authorization&quot;);<br><br>        if(authorizationHeader == null || !authorizationHeader.startsWith(&quot;Bearer&quot;)){<br>            httpResponse.setStatus(HttpServletResponse.SC_UNAUTHORIZED);<br>            Map&lt;String, Object&gt; tokenReponse = new HashMap&lt;&gt;();<br>            tokenReponse.put(&quot;status&quot;, &quot;false&quot;);<br>            tokenReponse.put(&quot;error&quot;, &quot;Unauthorized&quot;);<br>            tokenReponse.put(&quot;message&quot;, &quot;invalide-token&quot;);<br>            objectMapper.writeValue(res.getWriter(), tokenReponse);<br>            return;<br>        }<br><br>        String token = authorizationHeader.substring(7);<br>        System.out.println(&quot;Token : &quot;+ token);<br>        try{<br><br>            Claims claims = Jwts.parser()<br>            .setSigningKey(SECRET_KEY)<br>            .parseClaimsJws(token)<br>            .getBody();<br><br>            httpRequest.setAttribute(&quot;uid&quot;, claims.getSubject());<br>            httpRequest.setAttribute(&quot;email&quot;, claims.get(&quot;email&quot;));<br>            httpRequest.setAttribute(&quot;userName&quot;, claims.get(&quot;username&quot;));<br><br>            chain.doFilter(req, res);<br>        }catch(SignatureException e){<br>            httpResponse.setStatus(HttpServletResponse.SC_UNAUTHORIZED);<br>            Map&lt;String, Object&gt; tokenReponse = new HashMap&lt;&gt;();<br>            tokenReponse.put(&quot;status&quot;, &quot;false&quot;);<br>            tokenReponse.put(&quot;error&quot;, &quot;Unauthorized&quot;);<br>            tokenReponse.put(&quot;message&quot;, &quot;Invalid token signature&quot;);<br>            objectMapper.writeValue(res.getWriter(), tokenReponse);<br>        }catch(Exception e){<br>            httpResponse.setStatus(HttpServletResponse.SC_UNAUTHORIZED);<br>            Map&lt;String, Object&gt; tokenReponse = new HashMap&lt;&gt;();<br>            tokenReponse.put(&quot;status&quot;, &quot;false&quot;);<br>            tokenReponse.put(&quot;error&quot;, &quot;Unauthorized&quot;);<br>            tokenReponse.put(&quot;message&quot;, &quot;Token validation failed&quot;);<br>            objectMapper.writeValue(res.getWriter(), tokenReponse);<br>        }<br>    }<br><br>    @Override<br>    public void destroy(){}<br>}</pre><h3>Step 6: App.js (Server Initialization)</h3><p>The App.js file serves as the entry point for starting the Jetty server. It connects the application to the database, maps routes to the AuthController, and applies the JwtFilter for token validation.</p><pre>package com.back;<br>import org.eclipse.jetty.server.Server;<br>import org.eclipse.jetty.servlet.ServletContextHandler;<br>import org.eclipse.jetty.servlet.ServletHolder;<br>import java.sql.Connection;<br>import java.sql.DriverManager;<br>public class App {<br>    public static void main(String[] args) {<br>        try {<br>            // Initialize the database connection<br>            String dbUrl = &quot;jdbc:mysql://localhost:3306/your_database&quot;;<br>            String dbUser = &quot;your_username&quot;;<br>            String dbPassword = &quot;your_password&quot;;<br>            Connection connection = DriverManager.getConnection(dbUrl, dbUser, dbPassword);<br>            // Initialize the Jetty server<br>            Server server = new Server(8080);<br>            ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);<br>            // Set the server context path<br>            context.setContextPath(&quot;/&quot;);<br>            server.setHandler(context);<br>            // Add AuthController for authentication routes<br>            AuthController authController = new AuthController(connection);<br>            context.addServlet(new ServletHolder(authController), &quot;/auth/*&quot;);<br>            // Apply JwtFilter for protected routes<br>            context.addFilter(JwtFilter.class, &quot;/protected/*&quot;, null);<br>            // Start the server<br>            server.start();<br>            server.join();<br>        } catch (Exception e) {<br>            e.printStackTrace();<br>        }<br>    }<br>}</pre><p>This system ensures a secure, scalable foundation for managing user authentication in your Java projects. You can now expand it further to include additional features like role-based access, password resets, or OAuth integrations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01720d4d7944" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up Local Storage in Your Flutter App with SQLite]]></title>
            <link>https://awstip.com/setting-up-local-storage-in-your-flutter-app-with-sqlite-b931c1e86d0f?source=rss-2e69e67ee71d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b931c1e86d0f</guid>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[moblie-app]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[localstorage]]></category>
            <dc:creator><![CDATA[Morel Denzel]]></dc:creator>
            <pubDate>Sat, 18 Jan 2025 20:01:02 GMT</pubDate>
            <atom:updated>2025-01-21T19:08:15.285Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UJCDZQk5z6e-1xgB7AP3vQ.png" /></figure><p>SQLite is a lightweight database engine designed to provide fast, reliable, and efficient local storage, perfect for mobile and embedded systems like Flutter applications.</p><p><strong>Key Benefits of SQLite in Flutter Apps</strong></p><p>SQLite in general is a software library that implements a self-contained, serverless, zero-configuration, and transactional SQL database engine. Its simplicity and effectiveness make it widely adopted across mobile, desktop, and IoT applications. Here’s why SQLite is an excellent choice for Flutter:</p><ul><li><strong>Offline Functionality</strong>: Many apps, like task managers, e-commerce platforms, or media apps, need to store and retrieve data when offline. SQLite is ideal for these scenarios.</li><li><strong>Structured Data Management</strong>: Unlike using JSON or plain text files for storage, SQLite allows developers to organize data into tables, providing better scalability and query options</li><li><strong>Small Footprint</strong>: SQLite adds minimal size to your app’s package, making it suitable even for lightweight applications.</li><li><strong>Cross-Platform Support</strong>: SQLite works seamlessly on both Android and iOS, providing a unified solution for Flutter developers.</li></ul><p>Here, we’ll cover how to set up SQLite in a Flutter app from installation to usage, using an example implementation.</p><h4>Step 1: Install Required Dependencies</h4><p>To integrate SQLite into your Flutter project, you’ll need two main packages:</p><ol><li><strong>sqflite</strong>: For SQLite database handling.</li><li><strong>path_provider</strong>: For locating the app’s file storage directories.</li></ol><p>Add the following dependencies to your pubspec.yaml file:</p><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br>  sqflite: ^2.2.5<br>  path_provider: ^2.0.13</pre><p>Run the following command to install the dependencies:</p><pre>flutter pub get</pre><h3>Step 2: Create a Database Helper Class</h3><p>The database helper class will manage all database operations, including initialization, table creation, and CRUD (Create, Read, Update, Delete) operations. Below is an example implementation:</p><p><strong>Database Initialization</strong></p><p>In any app using SQLite for local storage, the first and most critical step is initializing the database. This process involves setting up the database instance, defining the file location, and creating the necessary tables.</p><pre>static final DatabaseHelper instance = DatabaseHelper._internal();<br><br>  static Database? _database;<br>  final String databaseName = &quot;app_data.db&quot;;<br><br>  static final String userTable = &quot;users&quot;;<br>  static final String transactionTable = &quot;transactions&quot;;</pre><p>Let’s explore the three main methods of your database helper class — get database, _initDatabase, and _onCreate</p><h3>get database: Lazy Loading the Database</h3><p>This method provides access to the SQLite database instance and uses a technique called <em>lazy initialization</em>. Here’s how it works:</p><pre>Future&lt;Database&gt; get database async {<br>  if (_database != null) return _database!;<br>  _database = await _initDatabase();<br>  return _database!;<br>}</pre><p>This ensures that the database is only initialized once during the app’s lifecycle. By managing the database instance centrally, you avoid redundant initializations and ensure consistent access across your app.</p><h3>_initDatabase: Creating or Opening the Database</h3><p>This method initializes the SQLite database file and ensures it is stored in the correct location.</p><pre>Future&lt;Database&gt; _initDatabase() async {<br>  io.Directory documentDirectory = await getApplicationDocumentsDirectory();<br>  String path = join(documentDirectory.path, databaseName);<br>  return await openDatabase(path, version: 1, onCreate: _onCreate);<br>}</pre><p>Prepares the database for use by creating or opening the database file in the app’s local storage. Thus ensures that the database file is created or opened in the right location, this method guarantees your app can reliably store and retrieve data and it takes into consideration these aspects :</p><ul><li>getApplicationDocumentsDirectory() fetches the directory where the app can store its files (e.g., data/data/&lt;package&gt;/files for Android) and combines the directory path with the database file name (databaseName) to get the full file path.</li><li>openDatabase() opens the database if it exists; otherwise, it creates a new one. And as parameters it contains:</li></ul><p>— The version parameter specifies the database schema version.</p><p>— The onCreate parameter points to _onCreate, which defines the initial schema</p><h3>_onCreate: Defining the Database Schema</h3><p>This method is called when the database is created for the first time. It defines the tables and their structure.</p><pre>Future&lt;void&gt; _onCreate(Database db, int version) async {<br>  await db.execute(&#39;&#39;&#39;<br>    CREATE TABLE $userTable (<br>      id INTEGER PRIMARY KEY AUTOINCREMENT,<br>      name TEXT,<br>      email TEXT UNIQUE,<br>      phone TEXT,<br>      created_at TEXT<br>    )<br>  &#39;&#39;&#39;);<br><br>  await db.execute(&#39;&#39;&#39;<br>    CREATE TABLE $transactionTable (<br>      id INTEGER PRIMARY KEY AUTOINCREMENT,<br>      user_id INTEGER,<br>      amount REAL,<br>      type TEXT,<br>      date TEXT,<br>      FOREIGN KEY (user_id) REFERENCES $userTable (id)<br>    )<br>  &#39;&#39;&#39;);<br>}</pre><p>This sets up the initial database schema, defining how data will be stored.</p><p>With the database setup complete, we can now proceed to implement the logic required to interact with it effectively.</p><pre>import &#39;dart:io&#39; as io;<br>import &#39;package:path/path.dart&#39;;<br>import &#39;package:path_provider/path_provider.dart&#39;;<br>import &#39;package:sqflite/sqflite.dart&#39;;<br><br>class DatabaseHelper {<br> Let’s start by initalisiaing the database and it’s tables <br><br>```dart<br>  static final DatabaseHelper instance = DatabaseHelper._internal();<br><br>  static Database? _database;<br>  final String databaseName = &quot;app_data.db&quot;;<br><br>  static final String userTable = &quot;users&quot;;<br>  static final String transactionTable = &quot;transactions&quot;;<br>```<br>  DatabaseHelper._internal();<br><br>  Future&lt;Database&gt; get database async {<br>    if (_database != null) return _database!;<br>    _database = await _initDatabase();<br>    return _database!;<br>  }<br><br>  Future&lt;Database&gt; _initDatabase() async {<br>    io.Directory documentDirectory = await getApplicationDocumentsDirectory();<br>    String path = join(documentDirectory.path, databaseName);<br>    return await openDatabase(path, version: 1, onCreate: _onCreate);<br>  }<br><br>  Future&lt;void&gt; _onCreate(Database db, int version) async {<br>    await db.execute(&#39;&#39;&#39;<br>      CREATE TABLE $userTable (<br>        id INTEGER PRIMARY KEY AUTOINCREMENT,<br>        name TEXT,<br>        email TEXT UNIQUE,<br>        phone TEXT,<br>        created_at TEXT<br>      )<br>    &#39;&#39;&#39;);<br><br>    await db.execute(&#39;&#39;&#39;<br>      CREATE TABLE $transactionTable (<br>        id INTEGER PRIMARY KEY AUTOINCREMENT,<br>        user_id INTEGER,<br>        amount REAL,<br>        type TEXT,<br>        date TEXT,<br>        FOREIGN KEY (user_id) REFERENCES $userTable (id)<br>      )<br>    &#39;&#39;&#39;);<br>  }<br>}</pre><h3>Step 3: Perform CRUD Operations</h3><p>With the database and tables set up, you can now perform CRUD operations. Here’s how to implement each:</p><pre>// **Insert Data **************************************************************<br><br>Future&lt;int&gt; insertUser(Map&lt;String, dynamic&gt; user) async {<br>  final db = await instance.database;<br>  return await db.insert(DatabaseHelper.userTable, user);<br>}<br><br>Future&lt;int&gt; insertTransaction(Map&lt;String, dynamic&gt; transaction) async {<br>  final db = await instance.database;<br>  return await db.insert(DatabaseHelper.transactionTable, transaction);<br>}<br><br>// **Retrieve Data **************************************************************<br><br>Future&lt;List&lt;Map&lt;String, dynamic&gt;&gt;&gt; getAllUsers() async {<br>  final db = await instance.database;<br>  return await db.query(DatabaseHelper.userTable);<br>}<br><br>Future&lt;List&lt;Map&lt;String, dynamic&gt;&gt;&gt; getUserTransactions(int userId) async {<br>  final db = await instance.database;<br>  return await db.query(DatabaseHelper.transactionTable, where: &quot;user_id = ?&quot;, whereArgs: [userId]);<br>}<br><br>// **Update Data **************************************************************<br><br>Future&lt;int&gt; updateUser(int id, Map&lt;String, dynamic&gt; user) async {<br>  final db = await instance.database;<br>  return await db.update(DatabaseHelper.userTable, user, where: &quot;id = ?&quot;, whereArgs: [id]);<br>}<br><br>// **Delete Data **************************************************************<br><br>Future&lt;int&gt; deleteUser(int id) async {<br>  final db = await instance.database;<br>  return await db.delete(DatabaseHelper.userTable, where: &quot;id = ?&quot;, whereArgs: [id]);<br>}</pre><h3>Step 4: Using the Database in Your App</h3><h4>Adding a New User</h4><pre>void addUser() async {<br>  Map&lt;String, dynamic&gt; user = {<br>    &quot;name&quot;: &quot;John Doe&quot;,<br>    &quot;email&quot;: &quot;johndoe@example.com&quot;,<br>    &quot;phone&quot;: &quot;1234567890&quot;,<br>    &quot;created_at&quot;: DateTime.now().toString()<br>  };<br><br>  int id = await DatabaseHelper.instance.insertUser(user);<br>  print(&quot;User inserted with id: $id&quot;);<br>}</pre><h4>Fetching Users</h4><pre>void fetchUsers() async {<br>  List&lt;Map&lt;String, dynamic&gt;&gt; users = await DatabaseHelper.instance.getAllUsers();<br>  print(&quot;All Users: $users&quot;);<br>}</pre><p>With this fully functional SQLite setup in your Flutter app, you can manage data locally, providing fast and efficient offline capabilities for your app. Expand this setup by adding more tables, enhancing relationships, and implementing more complex queries.</p><p>Let me know how this works for you or if you’d like to explore advanced SQLite techniques in Flutter!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b931c1e86d0f" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/setting-up-local-storage-in-your-flutter-app-with-sqlite-b931c1e86d0f">Setting Up Local Storage in Your Flutter App with SQLite</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter: You uploaded Android App Bundle that was signed in debug mode — Fixed]]></title>
            <link>https://moreldenzel.medium.com/flutter-you-uploaded-android-app-bundle-that-was-signed-in-debug-mode-fixed-568016810eaf?source=rss-2e69e67ee71d------2</link>
            <guid isPermaLink="false">https://medium.com/p/568016810eaf</guid>
            <category><![CDATA[debug-mode]]></category>
            <category><![CDATA[app-bundle]]></category>
            <category><![CDATA[signing-key]]></category>
            <category><![CDATA[keystore]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Morel Denzel]]></dc:creator>
            <pubDate>Sat, 11 Jan 2025 20:17:49 GMT</pubDate>
            <atom:updated>2025-01-11T20:17:49.110Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KLPWYdVDr-yXvRXO7ry0xg.png" /></figure><h3>Flutter: You uploaded Android App Bundle that was signed in debug mode — Fixed</h3><p>If you’re trying to publish your Flutter app to the Google Play Store and you encounter the error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*me954lxbHkATDOTy61t0BQ.png" /></figure><p>You’re not alone. This is a common mistake among developers who are new to the Android app publishing process. But don’t worry! This guide will help you understand the reason behind this error and how to resolve it.</p><h3><strong>Why Does Google Play Require a Release-Signed Android App Bundle ?</strong></h3><p>When you upload App Bundle to the Google Play Store, the store needs to ensure that the app is coming from a legitimate source.</p><ul><li><strong>Security</strong>: By requiring release mode signing, Google ensures that only the developer (with the correct private key) can update the app. If the app were signed with a debug key, anyone could potentially modify the app and upload it to the Play Store, creating a major security risk.</li><li><strong>Integrity and Trust</strong>: Release mode ensures that the app has been packaged in the final production format, free from debug code and potential issues.</li><li><strong>Optimization</strong>: Apps in release mode are optimized for performance, so users get the best experience possible.</li></ul><h3>How to Fix This Error</h3><p><strong>Generate a Keystore:</strong></p><p>First, you need to generate a <strong>keystore file</strong> that will be used to sign your app in release mode.</p><blockquote>A <strong>keystore </strong>securely stores cryptographic keys to sign apps, ensure ownership, and protect against tampering or impersonation.</blockquote><p>In your terminal, run the following command:</p><pre>keytool -genkey -v -keystore /path/to/your/keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -keystore your-release-key.jks</pre><blockquote>Follow the prompts to set up the keystore and key. Remember to note the <strong>passwords </strong>and <strong>alias</strong> you set. because they can’t be viewed after.</blockquote><p>Configure <strong>build.gradle</strong>:</p><p>Inside your project, navigate to<strong> android &gt; app &gt; build.gradle</strong> and add this :</p><pre>    anddroid {<br>    ...<br>    <br>     signingConfigs {<br>         release {<br>             keyAlias &#39;your-key-alias&#39;<br>             keyPassword &#39;your-key-password&#39;<br>             storeFile file(&#39;your-path-to release-key.jks&#39;)<br>             storePassword &#39;your-store-password&#39;<br>         }<br>     }<br>    }</pre><p>you’re configuring the <strong>build.gradle</strong> file to enable release signing for your Flutter app. The <strong>signingConfigs</strong> block specifies the keystore file (<strong>release-key.jks</strong>), the keystore password, the key alias, and the key password required to securely sign the App bundle in release mode. These details ensure the app is uniquely identified and can only be updated with the same credentials, safeguarding against unauthorized updates.</p><h4>View Keystore Information</h4><p>In case you’ve forgotten your keystore informations, Use the following command to display the keystore and its aliases:</p><pre>keytool -list -v -keystore /path/to/release-key.jks</pre><p>Once everything is set up, you can rebuild the Android App Bundle:</p><blockquote>flutter clean</blockquote><blockquote>flutter pub get</blockquote><blockquote>flutter build appbundle — release</blockquote><p>After building the release App Bundle, you can now upload it to the Google Play Console without encountering the debug mode error. Hope that helped 😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=568016810eaf" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>