<?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 Yota Ishikawa on Medium]]></title>
        <description><![CDATA[Stories by Yota Ishikawa on Medium]]></description>
        <link>https://medium.com/@mxiskw?source=rss-8bb2a656b4e0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nbDMZTvsKGLG1wokimDyyA.png</url>
            <title>Stories by Yota Ishikawa on Medium</title>
            <link>https://medium.com/@mxiskw?source=rss-8bb2a656b4e0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 06:29:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mxiskw/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[Flutter | Pragmatic Architecture using Riverpod]]></title>
            <link>https://medium.com/@mxiskw/flutter-pragmatic-architecture-using-riverpod-123ae11a8267?source=rss-8bb2a656b4e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/123ae11a8267</guid>
            <category><![CDATA[riverpod]]></category>
            <category><![CDATA[freezed]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Yota Ishikawa]]></dc:creator>
            <pubDate>Sat, 05 Sep 2020 07:05:52 GMT</pubDate>
            <atom:updated>2021-11-21T15:02:17.875Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve come up with a <strong>pragmatic Flutter architecture using Riverpod</strong>, so I want to share it in this article. If you’re wondering what Riverpod is, check <a href="https://pub.dev/packages/riverpod">it</a> out first. It’s a new Flutter state management package. This architecture mainly use <strong>hooks_riverpod</strong> / <strong>flutter_hooks </strong>packages</p><p>日本語版は<a href="https://note.com/mxiskw/n/n78a69ca171cb">こちら</a></p><h3>What we will build</h3><p>We are going to build a <strong>minimum todo list</strong>. Because it is boring just to save data in memory, I will make it <strong>persistent save</strong> with SharedPreferences. If you make this external DB, the contents of this time can be diverted easily.</p><p>What the app can do is the following.<br>・The text that was input can be persisted as a Todo item.<br>・You can view persistent todo lists.<br>・You can sort the list by date in ascending or descending order.<br>・The completion flag can be made permanent by pressing the completion button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*3y2z3UGSXP2msmmtZf85ww.png" /></figure><h3>Architecture Diagram</h3><p>Here’s an illustration of the architecture that we’re going to look at. The arrows represent the flow of data. The characters are <strong>Entity</strong>, <strong>Repository</strong>, <strong>State</strong>, <strong>ViewController</strong>, and <strong>View</strong>. I wanted to keep the structure minimal, so I have narrowed it down to a few.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*sjQvmVfp9cI1fuYQAjWT0A.png" /></figure><p>If your app is becoming more complex, you can improve it by introducing things like Usecase between the Repository and ViewController.<br><strong>Entity</strong> here refers to a container of data corresponding to DB.<br>All items except View and Entity are declared based on Riverpod’s <strong>Provider</strong>.<br>Let’s look at each of them in detail.</p><h3>The dependencies</h3><pre>dependencies:<br> flutter:<br>   sdk: flutter<br><br> flutter_hooks: <br> hooks_riverpod: <br><br>dev_dependencies:<br> flutter_test:<br>   sdk: flutter </pre><h3>Entity</h3><p>Entity is a container of data corresponding to the schema of the database. It may be referred to in other ways, but you can convert it as you see fit.<br>Entities are used everywhere, from displaying data to retrieving data. This Entity can be made immutable to make it easier to handle, and the merits of immutability are summarized by Remi, the author of Riverpod:</p><h3>Remi Rousselet on Twitter: &quot;Immutability is overpowered.You get so many things for free.Some examples:- fewer bugs- undo/redo/history- animations (tweens)- easy to know if something hasn&#39;t changed- easy tests- no surprise / Twitter&quot;</h3><p>Immutability is overpowered.You get so many things for free.Some examples:- fewer bugs- undo/redo/history- animations (tweens)- easy to know if something hasn&#39;t changed- easy tests- no surprise</p><p>However, the cost of making it immutable is that it cannot be modified, and you will need to use functions such as copyWith instead. There is a useful package called freezed that generates these functions for you, but it requires you to generate the code, which tends to confuse you during development. For this reason, I do not use freezed now, but instead use IntelliJ plugin called Dart Data Class to create functions such as copyWith / fromMap / toMap.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e7e2a631306f55ff4ddd6cf5d0290c98/href">https://medium.com/media/e7e2a631306f55ff4ddd6cf5d0290c98/href</a></iframe><h3>Repository</h3><p>In Repository, we write the process to CRUD data. It is convenient to define it in an abstract class (so-called interface) so that you can easily add dummy implementations or connect to an external DB later. In this implementation, we will get the SharedPreferences and CRUD the data. If you are going to use it, you might want to add some error handling. I won’t explain the details of SharedPreferences since it’s not the main focus of this article. The important point is the line that defines the <strong>todoRepository</strong>. This will allow you to access it from ProviderReference.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c030c5889b0f8911a7d6a5be4937235b/href">https://medium.com/media/c030c5889b0f8911a7d6a5be4937235b/href</a></iframe><h3>State</h3><p>State is where the state is stored in memory. It is also where you define information such as Getter that is calculated from the values of other States. In this project, we will prepare three states, and by defining them as StateProvider, View and <strong>ref.watch</strong> will be automatically notified when the state variable inside is changed. Of these, <strong>_todoListState</strong> and <strong>_sortOrderState</strong> are defined as private variables since they do not need to be accessed directly by View.</p><p><strong>1. Todo list value (_todoListState)<br></strong>The reason the initial value of the Todo List is null instead of an empty array is to determine if the value was retrieved and is empty, or if it hasn’t been retrieved yet.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70b204cc5dfaf4eef02e1277ebf3c787/href">https://medium.com/media/70b204cc5dfaf4eef02e1277ebf3c787/href</a></iframe><p><strong>2. Sort order value (_sortOrderState)<br></strong>define sort order as enum</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3eff805d35e04f3af51358f9708b8a00/href">https://medium.com/media/3eff805d35e04f3af51358f9708b8a00/href</a></iframe><p><strong>3. Sorted Todo list value (sortedTodoListState)</strong></p><p>The calculation is based on the values of <strong>_todoListState</strong> and <strong>_sortOrderState</strong>. If they are changed, they are automatically calculated again.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a6142cde530669bf9e0ec30809628bd/href">https://medium.com/media/8a6142cde530669bf9e0ec30809628bd/href</a></iframe><h3>ViewController</h3><p>The <strong>ViewController</strong> takes commands from the View, such as user input, and writes processes that reflect them to the <strong>Repository</strong> and <strong>State</strong>. The modified State is reflected in the View.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4bddd5d5a8626fdbd9a7150dc97dc338/href">https://medium.com/media/4bddd5d5a8626fdbd9a7150dc97dc338/href</a></iframe><h3>View</h3><p>Finally, let’s take a look at the View, and following is the full code for the View, which extends <strong>HookConsumerWidget</strong> and allows for functions to access a Provider, such as ref.watch. The <strong>useEffect</strong> is a bit trickier to explain, so we’ll follow.</p><p>Basically, in the build, we just use <strong>ref.watch</strong> to access <strong>State</strong>, and in the onPressed, we just use <strong>ref.read</strong> to access the <strong>ViewController</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/13360a71ea46ade57fe59e8e5ac1f261/href">https://medium.com/media/13360a71ea46ade57fe59e8e5ac1f261/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e7cdf0f1e2a351c07ebc54e0030afb9/href">https://medium.com/media/2e7cdf0f1e2a351c07ebc54e0030afb9/href</a></iframe><p>The <strong>useEffect</strong> called within the build method serves as an alternative to the initState and dispose of StatefulWidget. useEffect’s first argument calls a function that causes a side-effect in the body, and the return value is specifying the functions that will be called when the widget is destroyed, <strong>similar to StatefulWidget</strong>. Here, we’re calling initState and dispose, which are defined in the ViewController, similar to StatefulWidget (we’re actually using <strong>.autoDispose</strong>, so we don’t need the dispose function). Then, we can pass an array of keys as the second argument. If the key is changed, the first argument is executed again. Since we didn’t pass anything here, <strong>it won’t be called again</strong> unless the widget is destroyed.</p><p>And finally, don’t forget to define a ProviderScope in main.dart.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed89e5d738ae72c80189c291d0b9bbf9/href">https://medium.com/media/ed89e5d738ae72c80189c291d0b9bbf9/href</a></iframe><h3>Test</h3><p>One of the merits of building an architecture with Riverpod is that the tests are very easy to write and read. This is where the benefit of defining the TodoRepository in an interface comes in: you can override the Provider’s content by using the Provider’s <strong>overrideWithProvider</strong> function (here, the TodoRepositoryImpl is set to overridden by _TodoRepositoryImplDummy).<br>To access each Provider from the test code, the <strong>ProviderContainer</strong> is defined. It is thought that it is enough to confirm that <strong>the State is changed by executing ViewController</strong> for the contents to be tested. The following is the code for testing all of the ViewController functions created this time. It’s minimal, but you can see that it can be written neatly.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/716a1702735fb826d10cb75d1d4af1fc/href">https://medium.com/media/716a1702735fb826d10cb75d1d4af1fc/href</a></iframe><h3>Finally</h3><p><strong>&lt;&lt;Summary of this architecture&gt;&gt;<br></strong>✅ Taking full advantage of <strong>Riverpod<br></strong>✅ Entity is corresponding to DB scheme<br>✅ Repository fetch the data<br>✅ Never write any logic in the <strong>View</strong><br>✅ Make data flow <strong>intuitive</strong><br>✅ Repository is declared as a <strong>interface</strong><br>✅ If it is fine by private then declare as <strong>private</strong><br>✅ Use <strong>StateProvider</strong> to store the data<br>✅ Declare the state as the <strong>smallest unit</strong><br>✅ Having a page-by-page <strong>ViewController</strong><br>✅ Basically, use <strong>.autoDispose</strong><br>✅ Use <strong>Hooks</strong> such as useTextEditingController<br>✅ Use <strong>useEffect</strong> to initialize the state<br>✅ Only <strong>State</strong> and <strong>ViewController</strong> communicate with the <strong>View</strong></p><p>I hope you found this article helpful.<br>There is no right answer to the architecture, so please use it as a reference and optimize it for your own project.<br>A working example is on the git: <a href="https://github.com/ttlg/riverpod_todo">https://github.com/ttlg/riverpod_todo</a><br>If you have any improvements or questions, please leave some reaction😄<br>Thanks!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=123ae11a8267" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter, This is it]]></title>
            <link>https://medium.com/@mxiskw/flutter-this-is-it-beb9683bb438?source=rss-8bb2a656b4e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/beb9683bb438</guid>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Yota Ishikawa]]></dc:creator>
            <pubDate>Fri, 14 Dec 2018 10:01:07 GMT</pubDate>
            <atom:updated>2021-07-26T17:47:19.299Z</atom:updated>
            <content:encoded><![CDATA[<h4>impression &amp; tips of developing production flutter app</h4><p>This article shares my experience &amp; some tips after development of production Flutter app.</p><h3>My story</h3><p>I am software engineer and I have been experienced in developing a wide range of frontend stack from <strong>OpenGL</strong> to <strong>HTML</strong>. Since 2013, I had been searching the way to develop iOS/Android applications from single codebase because I was too lazy to study two different platform. At that time, options were like <strong>Cordova</strong>(HTML,CSS, JS), <strong>Xamarin</strong>(C#), <strong>RoboVM</strong>(Java), <strong>Qt</strong>(C++), <strong>cocos2D-x</strong> (C++), <strong>Unity</strong> (C#, JS), <strong>kivy</strong>(Python), <strong>RubyMotion</strong>(Ruby). Now we have <strong>ReactNative</strong>(JSX), <strong>PWA</strong> (JS), <strong>Native Script</strong>(JS), <strong>Kotlin Native</strong>(Kotlin), and <strong>Flutter</strong> (Dart). When I met Flutter, I easily fell in love with it because of its capability. So I convinced my colleagues and boss to use Flutter for our production app. And completed development in December 2018. Of course we did care about other frameworks including ReactNative. ReactNative is a React based mobile library. It may good for an engineer who experienced a lot in React. However In my opinion, React itself is not so good. Vue.js is much better for building SPA app. Here(<a href="https://www.timqian.com/star-history/#facebook/react-native&amp;flutter/flutter">https://www.timqian.com/star-history/#facebook/react-native&amp;flutter/flutter</a>) is the Github star history comparing Flutter and ReactNative. You can see that Flutter is <strong>gaining stars with overwhelming speed.</strong> This means Flutter is gaining more and more attentions of mobile developer all over the world. Some Android developers say that they want to choose Flutter even if they only target Android. I bet Flutter will be the de fact standard of cross platform applications library in next year.</p><h3>Why Flutter</h3><p>Then, what makes Flutter so special? I think the most important characteristics of Flutter is<strong> Productivity </strong>which enables us super fast mobile app development. That<strong> Productivity</strong> is coming from:</p><ul><li><strong>Skia rendering engine</strong> … Unlike ReactNative or other frameworks, Flutter have its own rendering engine called Skia, it does not use native view. This enables us develop <strong>consistent UI</strong> between iOS &amp; Android. We do not have to worry about differences between them. You can focus on developing one platform. After the development of one platform, it runs exactly same view on one another. And it leads to productivity.</li><li><strong>Pre-made UI Widget</strong> … Flutter provides a lot of pre-made UI widget. We did not install 3rd-party UI library because these widget are <strong>beautiful</strong> enough. These widgets are based on Material Design and you can customize it. If you do not like Materiel Design, Flutter is not suitable.</li><li><strong>Easy installation &amp; easy configuration</strong> … Unlike any other frameworks, installation, configuration, and upgrading is pretty easy. For install, you just download SDK and configure it. If you run the flutter doctor -v command, it tells you how to setting up. Super useful.</li><li><strong>Stateful hot reload </strong>… hot reloading is one of the key factor of Flutter, and it enables us instant feedback of UI/Behavior changes. Stateful means that it preserve memory data when hot reloading.</li><li><strong>Easy integration of</strong> <strong>Firebase </strong>… If you will use Firebase as a DB, it is pretty easy to integrate Firebase with Flutter since they are Google’s products. Firebase plugins are maintained by them.</li><li><strong>Well documented</strong> ... The official documentation is well aligned and it is easy to read. Also, offline documentation keeping us on the editor.</li><li><strong>It’s Fun</strong>! ... Finally, developing with Flutter is really enjoyable.</li></ul><p>I think Flutter only have a few problems. One of the big problem is that <strong>3rd-party plugins/packages are not mature.</strong> But it also means<strong> </strong>you have a chance to contributing to the community. I will share some tips for beginners of Flutter in the section after here.</p><p>If you haven’t tried Flutter yet, just <strong>try</strong>!</p><p>Thank you for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=beb9683bb438" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>