<?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 Astrida Nayla on Medium]]></title>
        <description><![CDATA[Stories by Astrida Nayla on Medium]]></description>
        <link>https://medium.com/@astridanayla?source=rss-1b58991db158------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*O8s17X9fwpBD5QDAhv53PQ.jpeg</url>
            <title>Stories by Astrida Nayla on Medium</title>
            <link>https://medium.com/@astridanayla?source=rss-1b58991db158------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 20:58:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@astridanayla/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[Custom Reusable Search Bar in Flutter]]></title>
            <link>https://astridanayla.medium.com/membuat-custom-reusable-search-bar-dengan-flutter-1af880d060a5?source=rss-1b58991db158------2</link>
            <guid isPermaLink="false">https://medium.com/p/1af880d060a5</guid>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Astrida Nayla]]></dc:creator>
            <pubDate>Tue, 08 Jun 2021 01:30:14 GMT</pubDate>
            <atom:updated>2023-05-03T15:17:39.835Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BqyT293HGanhvkGxBDm_0g.png" /><figcaption>Ilustrasi search bar di aplikasi SIMPK BPKH</figcaption></figure><p>Flutter merupakan salah satu teknologi<em> open-source</em> untuk<em> mobile developmen</em>t yang banyak digunakan saat ini. Flutter dipercaya lebih mudah untuk dipahami oleh <em>mobile developer</em> pemula dibanding teknologi <em>mobile development </em>lainnya. Pemrograman <em>frontend</em> aplikasi <em>mobile</em> pada Flutter dipermudah dengan keberadaan <em>built-in </em><strong>widgets</strong> yang mudah untuk dipakai dan dimodifikasi. Pada artikel ini, saya akan membahas bagaimana tim saya menggunakan Flutter untuk membuat komponen <em>custom</em> <em>search bar </em>yang bersifat <em>reusable</em>.</p><h3><strong>Tentang Flutter</strong></h3><p>Flutter adalah <em>software development kit (SDK)</em> bersifat <em>open-source</em> yang dikembangkan oleh Google. Dengan Flutter, aplikasi yang dikembangkan dapat diakses di berbagai <em>platform</em> meski hanya dibuat dari satu <em>codebase</em>. Flutter sendiri menggunakan bahasa pemrograman <strong>Dart</strong> yang juga dikembangkan oleh Google.</p><p>Keunggulan dari Flutter:</p><ul><li>Memiliki fitur <strong>hot reload</strong> yang mempercepat proses kerja, kita bisa langsung melihat perubahan tanpa perlu <em>build</em> dari awal.</li><li>Bahasa pemrograman yang digunakan, yaitu Dart, tidak jauh berbeda dengan Java.</li><li>Memiliki berbagai koleksi <em>user interface (UI) elements </em>yang bisa langsung dipakai, berdasarkan <em>design system</em> <strong>Google Material Design </strong>yang telah terbukti kualitasnya. <em>UI elements</em> tersebut juga mudah dimodifikasi sesuai keinginan.</li><li>Tampilan aplikasi yang dibuat dengan Flutter akan sama di berbagai <em>platform</em> tanpa perlu ada banyak penyesuaian.</li></ul><p>Dengan pengetahuan ini, tim saya memutuskan untuk menggunakan Flutter dalam proyek perangkat lunak kami. Mula-mula, kami melakukan <em>set up</em> Flutter di komputer masing-masing. Langkah <em>set up</em> tersebut dapat dilihat di tautan ini. Setelah itu, kami mulai dari tahap <em>design</em> sebelum memasuki implementasi program.</p><h3><strong>#1 Membuat Desain</strong></h3><p>Untuk membuat <em>custom search bar</em>, pertama-tama kami mendesain panduan <em>UI element</em>-nya. Kami membuat sendiri desain <em>search ba</em>r-nya, dengan spesifikasi desain sebagai berikut.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_fSgnJfi_CTV80XUbWURCw.png" /><figcaption>Panduan UI element untuk search bar</figcaption></figure><p>Desain komponen kami juga menspesifikasikan state dari search bar ini untuk kasus-kasus tertentu. Setelah panduan UI element difinalisasi, barulah kami bisa mulai membuat program untuk search bar ini. Namun, mula-mula kami perlu membuat test terlebih dahulu.</p><h3><strong>#2 Membuat Test</strong></h3><p>Sesuai dengan aturan <strong>Test Driven Development</strong>, kami membuat <em>test</em> terlebih dahulu. Untuk membuat test <em>UI element</em> pada Flutter, cukup tes apakah <em>static elements</em>-nya sudah sesuai. Karena <em>search bar</em> bukan sebuah halaman, pertama-tama kita perlu membungkusnya dengan <em>widget</em> MaterialApp agar bisa di-<em>test</em>. Untuk itu, kami membuat fungsi berikut.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JACkxMTzWup2QPR9Nsox6A.png" /><figcaption>Fungsi yang membungkus widget dengan MaterialApp</figcaption></figure><p>Lalu, barulah kita membuat <em>unit test</em> yang sesuai. Untungnya, Flutter memiliki<em> built-in function </em>yang memudahkan <em>test</em> tampilan <em>widget</em> dalam berbagai kasus. Fungsi expect di Flutter mirip dengan fungsi assertEquals. Di contoh berikut, kami membuat <em>test</em> apakah <em>search bar </em>mengandung label dan <em>prefix icon</em> yang sesuai.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AzkNd8-oqa5j8EdYrV_6oQ.png" /><figcaption>Keseluruhan functional test untuk widget custom search bar</figcaption></figure><p>Jalankan <em>test</em> dan pastikan bahwa<em> test failed</em>, namun tidak <em>error</em>. Setelah itu, barulah kita membuat implementasi program yang sesungguhnya.</p><h3><strong>#3 Implementasi Program</strong></h3><p>Sebelum membuat program, perlu diketahui bahwa search bar merupakan <strong>stateful widget</strong>. <em>Stateful widget </em>adalah widget yang dinamis, dapat berubah tampilan berdasarkan kejadian yang disebabkan oleh interaksi pengguna atau ketika ia menerima data. <em>Search bar</em> merupakan <em>stateful widget </em>karena ia bersifat dinamis terhadap <em>input</em> dari pengguna.</p><p><strong>Pertama</strong>, kita membuat class <em>search bar</em> yang<em> extend class </em>StatefulWidget. Jangan lupa untuk meng-<em>import package</em> yang sesuai.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*54BegniOdFV1-OgFMkB3FQ.png" /><figcaption>Membuat class search bar yang extend StatefulWidget</figcaption></figure><p><strong>Kedua</strong>, agar <em>search bar </em>bersifat <em>reusable</em>, maka kita perlu menspesifikasikan parameter. Parameter merupakan aspek dari <em>search bar</em> yang implementasinya dapat beragam, misalkan teks untuk label.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*tvnOFrmWdTmaqAurFw6Lwg.png" /><figcaption>Menspesifikasikan parameter untuk widget search bar</figcaption></figure><p><strong>Ketiga</strong>,<em> search bar </em>pada dasarnya adalah sebuah <em>widget</em> TextFormField yang dimodifikasi. Sehingga, kami menggunakan <em>widget</em> tersebut dengan mengubah beberapa parameternya agar bisa berfungsi sebagai <em>search bar</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*eANaALsvxC6fNyItApxAvw.png" /><figcaption>Implementasi program untuk widget custom search bar</figcaption></figure><p><strong>Keempat</strong>, beri tambahan di InputDecoration agar tampilan<em> search bar</em> sesuai dengan desain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*JAUqFCcZX-ZtlzjLzc29qg.png" /><figcaption>Menambah parameter InputDecoration untuk mengatur tampilan search bar</figcaption></figure><p>Hore! Akhirnya kita berhasil membuat <em>custom search bar</em> yang <em>reusable</em>. Untuk menggunakannya, cukum <em>import file</em> Dart berisi <em>search bar</em>-nya ke file Dart dimana search bar tersebut akan digunakan. Lalu, panggil <em>widget</em>-nya dan spesifikasikan parameternya. Berikut merupakan contoh implementasinya.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*QDt7ERlZpHBvd02RKWGv0Q.png" /><figcaption>Contoh pemanggilan custom search bar di file lain</figcaption></figure><p>Dengan ini, program kita tidak hanya lebih terbaca, namun kita juga dapat menghemat waktu pengerjaan. Kita dapat mengimplementasikan proses ini untuk elemen-elemen UI lain selain <em>search bar </em>pada aplikasi kita.</p><h3><strong>Kesimpulan</strong></h3><p>Flutter merupakan teknologi<em> open-source </em>yang dapat memudahkan kita untuk membuat aplikasi <em>mobile</em> dengan <em>built-in widgets</em>-nya. Pada Flutter, terdapat dua macam <em>widget</em>, yaitu <em>stateful widget</em> dan<em> stateless widget</em>. Pada artikel kali ini, saya membahas bagaimana saya membuat <em>custom search bar </em>yang merupakan <em>stateful widget</em>. Sebagai <em>mobile developer </em>pemula, saya sangat merekomendasikan Flutter, karena mudah dipahami dan bahasanya cukup familiar.<em> Search bar</em> merupakan contoh <em>widget</em> sederhana yang bisa kita coba. Nanti, semakin terbiasa dengan Flutter, kita akan bisa membuat berbagai <em>widget</em> yang lebih kompleks seperti <em>card</em>, <em>date</em> <em>picker</em>, dan <em>time picker</em>. Semoga artikel ini bisa berguna bagi kalian yang ingin belajar menggunakan Flutter!</p><h4>Referensi:</h4><ul><li><a href="https://relevant.software/blog/top-8-flutter-advantages-and-why-you-should-try-flutter-on-your-next-project/">https://relevant.software/blog/top-8-flutter-advantages-and-why-you-should-try-flutter-on-your-next-project/</a></li><li><a href="https://flutter.dev/docs/development/ui/interactive">https://flutter.dev/docs/development/ui/interactive</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1af880d060a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lighthouse : Design System for SIMPK BPKH App]]></title>
            <link>https://astridanayla.medium.com/lighthouse-design-system-for-simpk-bpkh-app-1c2f4d25ec63?source=rss-1b58991db158------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c2f4d25ec63</guid>
            <category><![CDATA[flutter-ui]]></category>
            <category><![CDATA[ui-design]]></category>
            <category><![CDATA[ux-design]]></category>
            <category><![CDATA[user-interface]]></category>
            <category><![CDATA[design-systems]]></category>
            <dc:creator><![CDATA[Astrida Nayla]]></dc:creator>
            <pubDate>Tue, 25 May 2021 01:27:55 GMT</pubDate>
            <atom:updated>2021-05-25T05:01:08.197Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Lighthouse : Design System for SIMPK BPKH App</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aFmNvYUMlCMIgMaLIUTp0g.png" /><figcaption>Lighthouse Design System for SIMPK BPKH</figcaption></figure><p>In this digital era, User Interface (UI) design has greatly evolved both in scale and efficiency. As the number of digital applications increases, designers are required to comply with the increasing demand for UI design at a fast pace. This is where the role of design systems came in. Some of us may refer to design systems using different terms such as design kit or design guidelines. Despite the naming difference, we can all agree that design system has become an important aspect in software development. In this article, I shall discuss the role of the Lighthouse design system in the development of SIMPK BPKH app.</p><h3><strong>About Design Systems.</strong></h3><p>According to <strong>Nielsen Norman Group</strong>,</p><blockquote><em>A design system is a complete set of standards intended to manage design at scale using reusable components and patterns (Fessenden, 2021).</em></blockquote><p>Based on that definition, a design system is a UI design guideline that is used to ensure design consistency, despite being worked on by many people. This is especially useful when you are working in a large team or organization, where communication might be a challenge. A design system is usually made before the process of designing the UI begins.</p><p>Nowadays, many big tech companies incorporate design systems in their UI design process. One famous example is Google, with their design system named Material Design. Design systems may differ from one another, adjusted to each of their own organization needs. However, based on the observable pattern of various design systems, we can conclude that most of them have these 2 elements in common:</p><ol><li><strong>Style Guide — </strong>provides a guide on visual branding and content delivery.</li><li><strong>Components — </strong>provides a guide on UI elements for both designers and developers.</li></ol><p>With this knowledge in mind, my team and I decided to implement a design system in the development process for the SIMPK BPKH app. In this project, my team was asked by BPKH as the client to design and implement the app based on the given requirements. This app will be the first mobile application to be used by BPKH. As a result, there are no specific guidelines for the design and the client leaves that matter up to my team. This became the main motivation for my team to develop a design system for the app.</p><h3><strong>Developing a Design System</strong></h3><p>Although it is not mandatory, it has been a common trait to have design systems named. My team and I decided to name our design system <strong>Lighthouse</strong>. Because, we hope that this design system can properly guide us to the right design, similar to what a lighthouse does.</p><h3><strong>Step 1: Style Guide</strong></h3><p>We began the process by determining the visual brand for the app. Our client does not provide specific branding requirements nor design benchmarks. Therefore, we first look for visual brand inspiration from <a href="https://bpkh.go.id/home-english/">BPKH&#39;s official site</a>. From the website, we got a glimpse of how the BPKH visual brand should look like.</p><h4><strong>Color</strong></h4><p>When determining color, it is important to understand the psychology behind it. Each color is associated with certain emotions. From BPKH’s official site and logo, we conclude that the primary brand color is dark blue. It makes sense since dark blue is associated with <strong>trust, responsibility, and security</strong>. These 3 values are in line with the purpose of BPKH as a government institution that manages the funding for Hajj pilgrims.</p><p>Now that we have the primary color, it is time to expand the color palette. A good color palette usually consists of primary and secondary colors. A style guide should also specify colors for certain states, like red for error states.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p0VsevwyLhMru5KYNle1cg.png" /><figcaption>Style Guide: Color for Lighthouse</figcaption></figure><p>Our primary color consists of blue shades because we want users to feel <strong>a sense of integrity and responsibility</strong> while using the app. We believe that these emotions are necessary for users when accessing a social welfare project monitoring app such as ours.</p><p>White will also act as the primary color for the background. Sure, dark mode is the new trend these days. But, we consider the fact that the app will mainly be used by middle-aged users who may have a difficult time reading the app content with a dark background. Also, the app will mainly be used outside on the field in the middle of the day. Therefore, it will be easier to see the contents of the app when the background has a light color.</p><h4><strong>Typography</strong></h4><p>The primary font family that we used for this design system will be <strong>Lato</strong>. It has a sans serif property, which we believe will bring a sense of formality to the design. Sans serif fonts are also easier to read. Lato is also a font that is available on Google Fonts, therefore we do not have to worry about any licensing issues.</p><p>In Lighthouse, typography includes guides on font size, font weight, font color, line height, and the context of use for a specific style of text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mG2Y_k1fOJ3fOoygLaMxfQ.png" /><figcaption>Style Guide: Typography for Lighthouse</figcaption></figure><h4><strong>Asset</strong></h4><p>Another aspect of the style guide that we should consider is assets. Luckily, the SIMPK BPKH app is an information system, therefore it does not require many assets. In Lighthouse, there are two types of assets that will be implemented on the app:</p><ul><li><strong>Logo </strong>— the original BPKH logo from the client, therefore we cannot alter the design of this logo. Logos are used in the app to establish identity, the organization this app belongs to.</li><li><strong>Icons </strong>— icons are used to signify certain information or action to users. In this design system, the icons used were Material Design icons made by Google. This will ease the development process because the app will be programmed in Flutter and the default icons in Flutter are from Material Design icons.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8_pMQ6rtYNYTSmD29BycBw.png" /><figcaption>Style Guide: Assets for Lighthouse</figcaption></figure><h3><strong>Step 2: Components</strong></h3><p>With the style guide established, my team then proceeds to design the components. Components are the UI elements that are put together to build an interface, usually made reusable to ensure consistency. Common aspects for components guide include:</p><ul><li><strong>Component name </strong>— a unique and specific name for each component. Unique and specific naming is important to avoid miscommunication.</li><li><strong>Description </strong>— a brief explanation of what the component is used for.</li><li><strong>Attributes </strong>— aspects of the component that can be customized or adjusted.</li><li><strong>State </strong>— visualize how the components will appear in a certain state.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s1t1hpRsifhsGg3k88r0UA.png" /><figcaption>An excerpt from the components library of Lighthouse</figcaption></figure><p>Another important aspect that is usually present in a components guide is <strong>code snippets</strong>. Code snippets are code excerpts that depict how a certain component is coded in the frontend. Our Lighthouse design system does not include code snippets because we believe that it is not necessary for a small-scale project such as ours. Besides, my team acted as both designer and developer, so there should be no issue if code snippets are not present.</p><p>With the style guide and components established, our Lighthouse design system is finally complete and ready to use. But, not so fast! Before we code straight to its functionality, it is best to create reusable components first in the project repository.</p><h3><strong>From Design System to Actual Code.</strong></h3><p>My team begins with translating the Lighthouse design system into reusable frontend codes. This will ease us as developers by <strong>reducing code duplications, maintaining clean code, and easier to test</strong>. In Flutter, we can achieve this by implementing themes and custom widgets.</p><h4><strong>Step 1: Create a theme.dart file</strong></h4><p>To create a style that would be implemented throughout the project, we can create a theme file. This theme file will return a ThemeData that defines typography, color, and widget styling on all pages of the app. We specify the entry of the ThemeData as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aaiddrnJFaWTqrP4fo01aA.png" /><figcaption>The code for the theme used on SIMPK BPKH app project</figcaption></figure><h4><strong>Step 2: Set up the theme for all pages</strong></h4><p>Now that the theme file is ready to use, simply import the dart file to the main.dart file. Then, in the MaterialApp class, set the theme parameter to the function found in your theme file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SIE6fRirdawtYL1UxGUgVQ.png" /><figcaption>Setting up the theme in main.dart</figcaption></figure><h4><strong>Step 3: Create custom reusable components with stateful and stateless widget</strong></h4><p>Now that the theme is set, my team then proceeds to create custom reusable widgets. In Flutter, there are two types of widgets, stateless and stateful widgets. Stateless widgets are static widgets that never change their appearance. Meanwhile, stateful widgets are widgets that can change their appearance at a certain state over time.</p><p>The code below is an example of a custom search bar component that is used for our SIMPK BPKH app. This search bar is a stateful widget because it can change appearance based on the state of input that the user provides for the search.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4nlxzLJNFd_4cyXtkt9nuA.png" /><figcaption>The code for custom search bar widget</figcaption></figure><h4><strong>Step 4: Implement custom reusable components</strong></h4><p>Once all reusable components are made, we can simply implement them by importing the widget to the designated dart file. Then, call the widget and specify its parameters if necessary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QG2Gh5aZqnkTtIs8Y-5exw.png" /><figcaption>Implementing the custom search bar on a page</figcaption></figure><p>Great! Now we have successfully implemented the design system as a frontend code. It’s been a long way indeed from the start. But why bother with all these steps? What can be gained by implementing a design system?</p><h3><strong>How Design System Benefit My Team.</strong></h3><p>As it turns out, the Lighthouse design system greatly benefits my team during the development process. Despite all the efforts it requires, I can guarantee that the benefits you could receive from the design system will be worth the effort. Below are some of the benefits of implementing a design system that I felt while developing the app.</p><h4><strong>Preserves Consistency</strong></h4><p>The use of design systems ensures consistency throughout the interface. In fact, consistency is one of the important aspects that makes a good UI design, as stated in Nielsen’s 10 Usability Heuristic. An inconsistent design can make users misunderstood the purpose of certain app functionality.</p><h4><strong>Saves Time and Effort</strong></h4><p>Design systems benefit both designers and developers by saving time and effort. This is made possible by the fact that design systems encourage <strong>reusability</strong>. Reusability means that new UI elements are made only if it is necessary. There is no need to create a new UI element if you can just reuse and customize the existing elements.</p><h4><strong>Help Reduce Miscommunication</strong></h4><p>In software development, we are often required to work in teams. Therefore, it may be difficult to ensure all members of the team think the same way. For example, the designer team intends for a card to be a carousel, but the developer team misinterprets the card as a dropdown instead. This kind of issue poses a challenge that can threaten design consistency and halt the development process. Therefore, design systems are required as a one-stop guide for all members involved in the development, to ensure that everyone has the same idea.</p><h3><strong>Conclusion: Is It Necessary?</strong></h3><p>The answer depends on the project and the team itself. If the scope of the project is small and the team members are only a few, then the absence of a design system will not become an issue. Also, if the design system only provides visual guides, then there should be no significant difference whether a design system is implemented or not. Therefore, we should consider implementing a design system based on the project’s scope and the team capacity. It is also important to consider the risk that inconsistency and inefficiency may pose on the development process.</p><p>After learning how to build a design system, I realized that I should have learned it sooner. I find that design systems are very useful to communicate with a fellow developer that has no sense of design. However, I do agree that building a design system can be difficult and time-consuming, so it is important to understand when it is necessary to do so. Hopefully, this article can introduce you to design systems and help you decide when to use a design system. Thank you and I’ll see you on the next one!</p><p>Reference:</p><ul><li><a href="https://www.nngroup.com/articles/design-systems-101/">https://www.nngroup.com/articles/design-systems-101/</a></li><li><a href="https://medium.com/nextux/a-quick-guide-to-creating-a-design-system-7888e267171f">https://medium.com/nextux/a-quick-guide-to-creating-a-design-system-7888e267171f</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c2f4d25ec63" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clean Code in Flutter With Lint]]></title>
            <link>https://astridanayla.medium.com/clean-code-in-flutter-with-lint-a5605c38dbbb?source=rss-1b58991db158------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5605c38dbbb</guid>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[lint]]></category>
            <dc:creator><![CDATA[Astrida Nayla]]></dc:creator>
            <pubDate>Mon, 05 Apr 2021 08:57:22 GMT</pubDate>
            <atom:updated>2025-07-30T08:36:32.854Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Clean code in Flutter with Lint</strong></h3><blockquote><strong><em>“Clean code is simple and direct. Clean code reads like well-written prose. Clean code never obscures the designer’s intent but rather is full of crisp abstractions and straightforward lines of control.”</em></strong></blockquote><blockquote>- Grady Booch, author of Object-Oriented Analysis and Design with Applications</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4JgDmG8qfDguNut3k_8Xxg.jpeg" /><figcaption>Illustration on Clean Code (<a href="https://www.lynda.com/Developer-tutorials/Clean-code-definition/2813150/2256495-4.html">Source</a>)</figcaption></figure><p>When I first heard of clean code, what comes to mind is a clear and structured program. Well, that’s partially correct, but there’s more to clean code than I thought. Clean code is an essential part of programming. Now it’s starting to make sense why my college professors highly encourage clean code on my programming assignments. Awesome!</p><p>So clean code, what does that even mean? Well, clean code is a practice to develop a program with high readability. By increasing our readability, hopefully, our program will be easier to understand, change, and maintain.</p><h3><strong>How to manifest clean code in our program?</strong></h3><p>As said before, clean code is an essential part of programming. A programmer should strive for good code, not just functionally but also structurally. What makes a good code? Below are some criterias that I consider to be fitting:</p><ul><li>A clear and consistent naming format for variable, class, and method names.</li><li>Class and method only have a single responsibility.</li><li>Clear and well-defined tests that are easy to understand and debug.</li><li>The role and responsibility of classes and methods are easily understood.</li><li>The execution flow of the entire application is easy to follow.</li></ul><h3><strong>How clean code benefit my team</strong></h3><p>There are a lot of benefits that programmers could achieve by practicing clean code. Sure, one may think that it requires extra effort and not as necessary as the program’s functionality. But, when you think of all the benefits you could get from clean code, you’ll realize why it’s worth all the effort. Below are some benefits that I felt as I implemented clean code on my project.</p><h4><strong>1. Easier to Understand</strong></h4><p>With clean code, our program will be easier to understand. Because, variables, methods, and classes are named according to their purpose. With clean code, classes and variables have a single responsibility. Programs are also structured properly with as few as possible code duplications. Combine all of them and programmers will not have a hard time guessing what a piece of the program does.</p><h4><strong>2. High Maintainability</strong></h4><p>As a programmer, we want our program to be highly maintainable in the long term. In order to do that, our program should be easily understood by other programmers. The purpose of clean code is to make our program readable and easy to understand. So, clean code helps our program to be easily maintained even by other people.</p><h4><strong>3. Easier to Test and Debug</strong></h4><p>Part of clean code is to build clear and well-defined tests. Building a clear and well-defined test could help us debug errors better, thus saving time and effort. Messy and convoluted codes are difficult to test too, so it is better to perform clean code in order to test your code better. Better tests help improve the quality of our program.</p><h3><strong>Clean code for Flutter frontend programming</strong></h3><p>There are various ways to implement clean code on Flutter frontend programming. Various open-source packages are also available to help Flutter developers practice clean code on their program. Here, I will discuss clean code on flutter using Lint.</p><h4><strong>1. Lint setup</strong></h4><p>To get started, simply add lint as a dependency to your pubspec.yaml file</p><pre>dev_dependencies:</pre><pre>   lint: ^1.0.0</pre><p>Now that we have lint set, it’s time to set the lint rules. You can add your custom rules in a file analysis_options.yaml that is located in the same directory as the pubspec.yaml file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*E9T_QhAYH34KP-in3Y1v5A.png" /><figcaption>Directory location for analysis_options.yaml</figcaption></figure><p>There are three types of rules in lint:</p><ul><li><strong>Error rules</strong>: rules related to the common errors that can occur in our program.</li><li><strong>Style rules</strong>: rules related to styles that are referred to in the Dart Style Guide.</li><li><strong>Pub</strong>: rules related to pub.</li></ul><p>You can apply your custom lint rules by adding ‘linter:’ to the analysis-options file. Then add ‘rules:’ followed by the specific rules you want to apply. You can check specific rules and their function in the lint documentation <a href="https://dart-lang.github.io/linter/lints/index.html">here</a>. Below is an example of my analysis-options file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*krE98nD_9EbnOIt7zDPLkw.png" /><figcaption>My personalized lint rules in analysis-options.yaml</figcaption></figure><h4><strong>2. Lint implementation</strong></h4><p>Below are some implementation examples based on the rules in my analysis-options file.</p><p><strong>[STYLE] Sort constructor declarators before other members and make static attributes of an immutable class final.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*HHmng6hnR1YcardfZtPY0g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*9zTSZZX-rMdWVluKlfFR7w.png" /><figcaption>Bad implementation (left) and good implementation (right)</figcaption></figure><p><strong>[STYLE] Clear and consistent naming for methods, classes, and variables with camel-case.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*3rr39_ZQ48Q2OunxXacG7w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*7V_AM4Nll1pFyp8fY_833w.png" /><figcaption>Bad implementation (left) and good implementation (right)</figcaption></figure><p><strong>[STYLE] Lines are no longer than 80 characters.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VABLvl0ufFDedxMcdQdNqQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aWPta8K8dGvNPgKLgMcrSQ.png" /><figcaption>Bad implementation (left) and good implementation (right)</figcaption></figure><p><strong>[ERROR] Always use package import.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*xSCywtxOn06IduyxY8QCJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*JoXOSfL_QgSYt5feyknImQ.png" /><figcaption>Bad implementation (left) and good implementation (right)</figcaption></figure><p><strong>[PUB] Sort pub dependency.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*Uh-Nzryls6jmWR1KaHYGJQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*Ii34YXqPHwnhKNUTj-QTmQ.png" /><figcaption>Bad implementation (left) and good implementation (right)</figcaption></figure><h3>Other non-lint clean code implementations</h3><h4><strong>1. Clear and well-defined tests that are easy to understand and debug</strong></h4><p>On my functional test for the frontend, I made sure that tests are named according to what it does. This will make it easier to debug should the test fails. I also ensure that each functional test does one specific responsibility only to ensure that it is readable by other programmers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*-qdqcPBuMHa-tlq7Z3zTlg.png" /><figcaption>A piece of unit test from my program</figcaption></figure><h4><strong>2. Single responsibility</strong></h4><p>Single responsibility means that a module, class, or function should only have one responsibility. This allows clean code by increasing the code readability, thus making it easier for other programmers to understand what the module, class, or function does.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*9gkfPpfQgRiyk6V7vjAe-w.png" /><figcaption>Some methods in my program that only implement a single purpose</figcaption></figure><h3><strong>Conclusion: Is It Necessary?</strong></h3><p>The answer depends on the programmer themselves. Are you willing to take the risks that may occur should clean code be absent in your project? Are you confident that others can easily understand your code as it is? It all depends on the purpose of implementing clean code in the first place. Therefore, clean code is necessary if we want our program to have high readability, maintainability, and easier to test and debug. But, if the code will only be used by you and you are satisfied with the code as it is, then there is no need for implementing clean code.</p><p>After learning about clean code implementation on Flutter, I realized that it is actually very easy to implement and does not take as much effort as it seems. I find that clean code is very useful when I’m working in teams where I’m not the only one who will use the code. Hopefully, this article can introduce you to clean code and provide insights on when to use clean code. Thank you and I’ll see you at the next one!</p><p>References:</p><ul><li><a href="https://garywoodfine.com/what-is-clean-code/">https://garywoodfine.com/what-is-clean-code/</a></li><li><a href="https://ptgmedia.pearsoncmg.com/images/9780132350884/samplepages/9780132350884.pdf">https://ptgmedia.pearsoncmg.com/images/9780132350884/samplepages/9780132350884.pdf</a></li><li><a href="https://medium.com/podiihq/setting-up-lint-rules-in-dart-flutter-1ebbed0418a6">https://medium.com/podiihq/setting-up-lint-rules-in-dart-flutter-1ebbed0418a6</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5605c38dbbb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>