<?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 Mahdiyar Arbabzi on Medium]]></title>
        <description><![CDATA[Stories by Mahdiyar Arbabzi on Medium]]></description>
        <link>https://medium.com/@m.arbabzi?source=rss-baa8046802cb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*EG4Y42-xndMcGXwF59lEJw.jpeg</url>
            <title>Stories by Mahdiyar Arbabzi on Medium</title>
            <link>https://medium.com/@m.arbabzi?source=rss-baa8046802cb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:20:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@m.arbabzi/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[How to create a backup from the Isar database and restore the backup file?]]></title>
            <link>https://medium.com/@m.arbabzi/how-to-create-a-backup-from-the-isar-database-and-restore-the-backup-file-4d6e974a688d?source=rss-baa8046802cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d6e974a688d</guid>
            <category><![CDATA[flutter-isar]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[local-database]]></category>
            <category><![CDATA[isar-database]]></category>
            <dc:creator><![CDATA[Mahdiyar Arbabzi]]></dc:creator>
            <pubDate>Sat, 09 Dec 2023 09:12:09 GMT</pubDate>
            <atom:updated>2023-12-09T09:12:09.825Z</atom:updated>
            <content:encoded><![CDATA[<p>As you know the <strong>Isar database</strong> is a popular local database on Flutter. It has complete documentation but I feel something is wrong with the documents! I think you can guess that…</p><p>After many searches, I couldn’t find any useful documents or a YouTube video that described to me, how can I create a backup file and use it.</p><blockquote>PS: There are some issues on the Isar Github repository and they try to describe this feature, but it’s not enough at all!</blockquote><p>here we are supposed to learn this feature of the Isar database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*l0w7e6Z0vkipgk7DoCg9DA.jpeg" /><figcaption>Isar Database recovery and backup</figcaption></figure><p><strong>First of all</strong>, you need to create a class for the Isar queries. I skip the CRUD queries and we are diving into creating a backup and restoring directly.</p><p>If you want to know the whole CRUD queries, you can watch this YouTube video:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FCwC9-a9hJv4%3Fstart%3D990%26feature%3Doembed%26start%3D990&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DCwC9-a9hJv4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FCwC9-a9hJv4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3139bbc15a35c945c65fe4e9b866a197/href">https://medium.com/media/3139bbc15a35c945c65fe4e9b866a197/href</a></iframe><h4>Opening Database</h4><p>Create “<strong><em>IsarService”</em></strong> class and implement the database opening method:</p><pre>import &#39;dart:io&#39;;<br><br>import &#39;package:isar/isar.dart&#39;;<br>import &#39;package:path/path.dart&#39; as p;<br>import &#39;package:path_provider/path_provider.dart&#39;;<br><br>class IsarService {<br>  late Future&lt;Isar&gt; db;<br><br>  IsarService() {<br>    db = openDB();<br>  }<br><br>  Future&lt;Isar&gt; openDB() async {<br>    if (Isar.instanceNames.isEmpty) {<br>      final dir = await getApplicationDocumentsDirectory();<br><br>      return await Isar.open(<br>        [<br>          CourseSchema,<br>          StudentSchema,<br>          TeacherSchema,<br>        ],<br>        directory: dir.path,<br>        inspector: true,<br>      );<br>    }<br><br>    return Future.value(Isar.getInstance());<br>  }<br>}</pre><p>As you see with the <strong>path provider</strong> package we have access to the <em>application documents directory</em> and we save the whole database in this directory.</p><blockquote>Isar creates a file<em> “</em><strong>default.<em>isar</em>” </strong>for all database data and we need this file<em> </em>when we want to restore our data.</blockquote><h4>Backup from database</h4><p>Create the backup method in the “<strong><em>IsarService</em></strong>” class:</p><pre>Future&lt;void&gt; createBackUp() async {<br>    final isar = await db;<br>    final backUpDir = await getApplicationSupportDirectory();<br><br>    final File backUpFile = File(&#39;${backUpDir.path}/backup_db.isar&#39;);<br>    if (await backUpFile.exists()) {<br>    // if already we have another backup file, delete it here.<br>      await backUpFile.delete();<br>    }<br><br>    await isar.copyToFile(&#39;${backUpDir.path}/backup_db.isar&#39;);<br>  }</pre><p>Here we create and save our backup file to the <em>application support directory </em>and named it “<strong><em>backup_db</em>.isar</strong>”. The function of creating the backup file is “<strong><em>copyToFile(backup path)</em></strong>”.</p><h4>Restore database data</h4><p>Create the restoring method in the “<strong><em>IsarService</em></strong>” class:</p><pre>Future&lt;void&gt; restoreDB() async {<br>    final isar = await db;<br>    final dbDirectory = await getApplicationDocumentsDirectory();<br>    final backupDirectory = await getApplicationSupportDirectory();<br><br>    // close the database before any changes<br>    await isar.close();<br><br>    final dbFile = File(&#39;${backupDirectory.path}/backup_db.isar&#39;);<br>    final dbPath = p.join(dbDirectory.path, &#39;default.isar&#39;);<br><br>    if (await dbFile.exists()) {<br>    // here we overwrite the backup file on the database file<br>      await dbFile.copy(dbPath);<br>    }<br>  }</pre><p>This method gets two different directories. The first one is the database file directory “<em>dbDirectory</em>” and the second one is the backup file directory “<em>backupDirectory</em>”.</p><p>Now we need to change the name of the backup file from “<strong><em>backup_db</em>.isar</strong>” to “<strong><em>default</em>.isar</strong>”, then move it to the database directory and overwrite on database file, and DONE!</p><p>Congratulations, now you have restored the backup files successfully.</p><p>This is my repository if you want to take a look at it: <a href="https://github.com/mahdiyarz/practice_isar_db">https://github.com/mahdiyarz/practice_isar_db</a></p><p>I hope this article can help you to learn how to implement these methods on the Isar databases.<strong> thanks for reading!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d6e974a688d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use the Flutter Gen package on Windows]]></title>
            <link>https://medium.com/@m.arbabzi/how-to-use-the-flutter-gen-package-on-windows-2bca85124b05?source=rss-baa8046802cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bca85124b05</guid>
            <category><![CDATA[flutter-gen]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter-package]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Mahdiyar Arbabzi]]></dc:creator>
            <pubDate>Sat, 17 Jun 2023 14:13:13 GMT</pubDate>
            <atom:updated>2023-06-17T14:26:59.054Z</atom:updated>
            <content:encoded><![CDATA[<p>Are you looking for an easy way to generate code for your Flutter app? Look no further than the Flutter Gen package! In this tutorial, we’ll walk you through the installation and setup of Flutter Gen so you can start generating code with ease.</p><p>Now step by step I’ll show you how to install it.</p><ul><li>Open up your terminal and run the following command:</li></ul><pre>dart pub global activate flutter_gen</pre><ul><li>Wait until receive the “Activated flutter_gen ^any version” command like here:</li></ul><pre>Building package executables... (19.3s)<br>Built flutter_gen:flutter_gen_command.<br>Installed executable fluttergen.<br>Warning: Pub installs executables into C:\Users\[user_name]\AppData\Local\Pub\Cache\bin, <br>which is not on your path.<br>You can fix that by adding that directory to your system&#39;s &quot;Path&quot; environment variable.<br>A web search for &quot;configure windows path&quot; will show you how.<br>Activated flutter_gen 5.3.1.</pre><p>As you see, we need to add the Flutter Gen path to the environment variables.</p><ul><li>Add Environment Variable</li></ul><blockquote>open the edit system environment variables and add “C:\Users\[user_name]\AppData\Local\Pub\Cache\bin” on Path</blockquote><ul><li>Add the following packages to your “pubspec.yaml” file under the “dev_dependencies” section:</li></ul><pre>dev_dependencies<br>  build_runner<br>  flutter_gen_runner</pre><p>Notice that these packages must add on “dev_dependencies” part and then run “flutter pub get”.</p><ul><li>Finally, run the following command in your application directory:</li></ul><pre>flutter packages pub run build_runner build</pre><h3><strong>That’s all…</strong></h3><p>Once the command line process is finished, a folder named gen will appear in your project directory, and you’re ready to start generating code!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bca85124b05" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Device Preview package]]></title>
            <link>https://medium.com/@m.arbabzi/device-preview-package-449459053c7?source=rss-baa8046802cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/449459053c7</guid>
            <category><![CDATA[flutter-widget]]></category>
            <category><![CDATA[device-preview]]></category>
            <category><![CDATA[package]]></category>
            <dc:creator><![CDATA[Mahdiyar Arbabzi]]></dc:creator>
            <pubDate>Sat, 02 Jul 2022 18:12:02 GMT</pubDate>
            <atom:updated>2022-07-02T18:27:14.456Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently I found a very useful package and want to introduce it to any one.</p><p>yes. It is <em>Device Preview </em>package. So if sound interesting to you, follow me here…</p><p>First we need install package on <em>pubspec.yaml </em>file<em>:</em></p><pre>device_preview: ^1.0.0</pre><p>Then import package on your <em>main.dart file:</em></p><pre>import ‘package:device_preview/device_preview.dart’;</pre><p>Now we can use <em>DevicePreview( )</em> widget like here:</p><pre>void main() { runApp(const MyApp());}<br></pre><pre>class MyApp extends StatelessWidget {</pre><pre>   const MyApp({Key? key}) : super(key: key);<br></pre><pre>   @override</pre><pre>   Widget build(BuildContext context) {</pre><pre>      return <em>DevicePreview</em>(</pre><pre><em>         enabled: !kReleaseMode,</em></pre><pre>         builder: (context) =&gt; MaterialApp(</pre><pre><em>            useInheritedMediaQuery: true,</em></pre><pre><em>            locale: DevicePreview.locale(context),</em></pre><pre><em>            builder: DevicePreview.appBuilder,</em></pre><pre>            title: ‘Flutter Demo’,</pre><pre>            theme: ThemeData(primarySwatch: Colors.blue,),</pre><pre>            home: const MyHomePage(title: ‘Flutter Demo Home Page’),),);}}</pre><p>Everything is ok and we run our flutter app on web platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tG96FwHSLKiQWWSvm2bhOA.png" /><figcaption>Device Preview package</figcaption></figure><p>This is so great to have access other devices or platform by any click and see what have you done there!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=449459053c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How can use flutter map and Mapbox with each other?]]></title>
            <link>https://medium.com/@m.arbabzi/how-can-use-flutter-map-and-mapbox-with-each-other-1fd57dc9623a?source=rss-baa8046802cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fd57dc9623a</guid>
            <category><![CDATA[map-api]]></category>
            <category><![CDATA[mapbox]]></category>
            <category><![CDATA[mapbox-studio]]></category>
            <category><![CDATA[flutter-maps]]></category>
            <dc:creator><![CDATA[Mahdiyar Arbabzi]]></dc:creator>
            <pubDate>Thu, 26 Aug 2021 13:28:54 GMT</pubDate>
            <atom:updated>2021-08-26T14:19:19.369Z</atom:updated>
            <content:encoded><![CDATA[<h3>How can use flutter map and Mapbox with each other</h3><p>First we need install flutter_map package on pubspec.yaml file and Configure your app to use internet permission in the manifest file located in <em>&lt;project root&gt;/android/app/src/main/AndroidManiFest.xml</em></p><pre>&lt;uses-permission android:name=”android.permission.INTERNET”/&gt;</pre><p>Now we can use FlutterMap() widget but you need create an account on <a href="https://account.mapbox.com/">Mapbox </a>and copy the “Default public token” at the first page of your account</p><p>Then click on “Design in Mapbox Studio” on “Tools &amp; resources” section like and click on “New style” at new page that open</p><figure><img alt="click on “Design in Mapbox Studio”" src="https://cdn-images-1.medium.com/max/1024/1*_hsQMgTStDKLMy7frawY9w.jpeg" /></figure><p>This page access you to chose any style what you want by click on “New Style” and these steps like bellow picture</p><figure><img alt="New Style Steps" src="https://cdn-images-1.medium.com/max/1024/1*18Y-dYi--7ZGU-Ht3kt9yg.jpeg" /></figure><p>Now you create your style and click on “Share your style” icon and go to “Third party” tab and chose “CARTO” then copy the “Integration URL”</p><figure><img alt="Share your style’s configuration" src="https://cdn-images-1.medium.com/max/1024/1*tXBkos8qvws8XjfLTr4Wlw.jpeg" /></figure><p>at the end go to “Tilesets” page and copy the ID of Tilesets as you like</p><figure><img alt="Tilesets ID" src="https://cdn-images-1.medium.com/max/1024/1*32koa945l1jfLpmbxeAEvQ.jpeg" /></figure><p>Let’s use FlutterMap() widget</p><pre>FlutterMap(<br>   options: <br>      MapOptions(<br>      center: LatLng(51.5, -0.09), <br>      zoom: 13.0,<br>      ),<br>   layers: [<br>      TileLayerOptions(<br>          urlTemplate: ‘use Integration URL here’, <br>          additionalOptions: {<br>              ‘accessToken’: ‘use Default public token here’, <br>              ‘id’: ‘use the ID of Tilesets here’,<br>              },<br>      ),<br>    ],<br> ),</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fd57dc9623a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>