<?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: Taiwo Divine</title>
    <description>The latest articles on DEV Community by Taiwo Divine (@taiwo_divine_8f40cd7c508d).</description>
    <link>https://dev.to/taiwo_divine_8f40cd7c508d</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2819989%2F29d744b2-65bf-4962-9254-653ce5f846ad.jpeg</url>
      <title>DEV Community: Taiwo Divine</title>
      <link>https://dev.to/taiwo_divine_8f40cd7c508d</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/taiwo_divine_8f40cd7c508d"/>
    <language>en</language>
    <item>
      <title>How to bundle Sqflite_common_ffi Database file in Windows .exe executable: Flutter Offline Desktop App</title>
      <dc:creator>Taiwo Divine</dc:creator>
      <pubDate>Wed, 05 Feb 2025 16:09:16 +0000</pubDate>
      <link>https://dev.to/taiwo_divine_8f40cd7c508d/how-to-bundle-sqflitecommonffi-database-file-in-windows-exe-executable-flutter-offline-desktop-3kgl</link>
      <guid>https://dev.to/taiwo_divine_8f40cd7c508d/how-to-bundle-sqflitecommonffi-database-file-in-windows-exe-executable-flutter-offline-desktop-3kgl</guid>
      <description>&lt;p&gt;&lt;strong&gt;Why I decided to write this post&lt;/strong&gt;&lt;br&gt;
I recently developed an inventory desktop application for a client using Flutter and online database. While the the app solved the client's need, the client soon became frustrated using the app due to low internet connection. I decided to introduce an offline version of the app because I like satisfying my clients. Whilst there are many options to choose from, I decided to settle with sqflite_common_ffi. &lt;/p&gt;

&lt;p&gt;I read through lots of related posts and watched some YouTube videos, and whilst some of the post made me realized I could include my database file through flutter assets (links below), still none of them gave detailed guide to put me through how to bundle Sqflite_common_ffi Database file with .exe executable. I had to rely on my instinct and eventually I scaled through. Hence, the reason I decided to write this post to continue where others stopped.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I hoped you already know&lt;/strong&gt;&lt;br&gt;
First, you should already know how to build Flutter desktop app in debug mode with backend capability before getting here. Second, in other not to re-invent the wheel, I will only mention and include links but won't repeat some steps which will be needed to complete this task.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's Get Started&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Step 1&lt;/strong&gt;: &lt;br&gt;
Build Your Flutter Desktop App - &lt;a href="https://docs.flutter.dev/get-started/install/windows/desktop" rel="noopener noreferrer"&gt;https://docs.flutter.dev/get-started/install/windows/desktop&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;: &lt;br&gt;
Add Database Capability - &lt;a href="https://pub.dev/packages/sqflite_common_ffi" rel="noopener noreferrer"&gt;https://pub.dev/packages/sqflite_common_ffi&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;: &lt;br&gt;
Include Database file inside asset folder - &lt;a href="https://github.com/tekartik/sqflite/blob/master/sqflite/doc/opening_asset_db.md" rel="noopener noreferrer"&gt;https://github.com/tekartik/sqflite/blob/master/sqflite/doc/opening_asset_db.md&lt;/a&gt;&lt;br&gt;
Notes on step 3: I recommend you use the getDatabasesPath() method to define your database path as that will make it easier for all your files to be bundle together after your desktop app is installed. If you use getApplicationDocumentsPath, your database file will be in the installed system document's directory while your app executables will be somewhere else.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4&lt;/strong&gt;: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run "flutter build windows --release" and navigate to the folder where the release executables are located. most likely it will be in the following path "{path_to_application}\build\windows\x64\runner\Release".&lt;/li&gt;
&lt;li&gt;Launch the Executable in this "Release folder" first before proceeding to the next step. This action will create another folder with your database file in the "Release" directory. &lt;strong&gt;Note&lt;/strong&gt;: &lt;em&gt;If you don't launch this executable before proceeding to step 5, your application will build successfully but the database file will not be bundled. It took me hours to discover this&lt;/em&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Step 5&lt;/strong&gt;&lt;br&gt;
Package and Distribute your Flutter Offline Desktop App - &lt;a href="https://medium.com/@fluttergems/packaging-and-distributing-flutter-desktop-apps-the-missing-guide-part-2-windows-0b468d5e9e70" rel="noopener noreferrer"&gt;https://medium.com/@fluttergems/packaging-and-distributing-flutter-desktop-apps-the-missing-guide-part-2-windows-0b468d5e9e70&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Endeavor to follow the steps in each steps and you will safely build your Flutter Offline Windows App. Should you need any help on this, comment on this post and I'll be willing to help.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>desktopapp</category>
      <category>offlineapp</category>
      <category>sqflitecommonffi</category>
    </item>
  </channel>
</rss>
