<?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 Nikita Sirovskiy on Medium]]></title>
        <description><![CDATA[Stories by Nikita Sirovskiy on Medium]]></description>
        <link>https://medium.com/@nivisi?source=rss-78ece1cfe53c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kF3Sh0yeyBmBWDJGJHexjA@2x.jpeg</url>
            <title>Stories by Nikita Sirovskiy on Medium</title>
            <link>https://medium.com/@nivisi?source=rss-78ece1cfe53c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 01:10:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nivisi/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[Moving build_runner to the Context Menu in VS Code]]></title>
            <link>https://nivisi.medium.com/moving-build-runner-to-the-context-menu-in-vs-code-c7bca88fcb69?source=rss-78ece1cfe53c------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7bca88fcb69</guid>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[code-generation]]></category>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Nikita Sirovskiy]]></dc:creator>
            <pubDate>Tue, 02 Apr 2024 11:21:10 GMT</pubDate>
            <atom:updated>2024-04-02T11:21:10.759Z</atom:updated>
            <content:encoded><![CDATA[<h4>Shorten build_runner run time &amp; regenerate only needed files in just two clicks.</h4><p>Quite a lot of Dart &amp; Flutter projects rely on code generation, delegating the burden of writing boilerplate code to a script. Although the more the project grows, the longer &amp; less attractive code generation becomes. I heard wild stories about code generation taking more than <em>half an hour </em>to rebuild everything (I’m sure there’s more). And simply using the watch command wasn’t helping: a small change was still triggering a few minutes of rebuilding.</p><p>Luckily, my situation is better. On my current project, it takes 4 minutes for my laptop to generate the code. Not that long, I agree. But we lose the beauty of hot reload if we need to wait until code generation completes.</p><p>So how do we keep it short &amp; convenient?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FdRdTUcyM20GUiQ8" /><figcaption>Photo by <a href="https://unsplash.com/@andriklangfield?utm_source=medium&amp;utm_medium=referral">Andrik Langfield</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Configuring the generators</h4><p>It is possible to tell specific code generation builders to work with needed files. For example, we can tell <a href="https://pub.dev/packages/freezed">Freezed</a> to generate only *_model.dart files. For this, we need to configure in the build.yaml file:</p><pre>targets:<br>  $default:<br>    builders:<br>      freezed:freezed:<br>        generate_for:<br>          include:<br>            - lib/**model.dart<br>            # Or we can limit it even more:<br>            - lib/data/**_dto.dart<br><br># Etc etc etc</pre><p>With this, we make sure that Freezed doesn’t work, say, with *_screen.dart or *_widget.dart classes. Similarly, we can exclude files.</p><p>While it’s great, it can still be quite time consuming to regenerate all the model classes in your project.</p><h4>Utilizing build-filter</h4><p>build_runner has a parameter build-filter that allows to specify which files to work with. It can be used for a single or multiple relative paths to files:</p><pre>dart run build_runner build  --release --build-filter=lib/data/ad<br>min.freezed.dart --build-filter=lib/data/admin.g.dart</pre><p>With this command, only the specified files will be regenerated.</p><blockquote>Note that this must be ran on <em>generated</em> files, not on <em>source</em> files. In the given example, admin.dart contains all the required freezed &amp; json_serializable configuration whereas .freezed.dart and .g.dart are generated files.</blockquote><p>But files are not always stored under lib/data. Your project might have a complex &amp; deep-nested folder structure making file paths long. Gathering these paths of required files, using them as build-filters, running a terminal command… Boring. Not mentioning we have to do it again for a new set of files.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F16756828&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Finception-deeper-go-deeper-we-need-to-go-deeper-leonardo-di-caprio-gif-16756828&amp;image=https%3A%2F%2Fmedia.tenor.com%2FEYPJjOVJOHYAAAAF%2Finception-deeper.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/1fc4033049d845aa9d958bba7dad4241/href">https://medium.com/media/1fc4033049d845aa9d958bba7dad4241/href</a></iframe><h4>Solution</h4><p>… is quite simple. Somehow optimize code generation by collecting relative paths of the required files &amp; passing it to build_runner automatically.</p><p>For example, we can move it to the context menu of the VS Code’s file explorer, so you can right click files and regenerate them. Like this:</p><figure><img alt="Example of running a build_runner process from the context menu." src="https://cdn-images-1.medium.com/max/1024/1*nQpHS-oDNEwoSjdpK7pFEA.gif" /><figcaption>Here’s how it’s going to look like.</figcaption></figure><h4>Bringing it to your table</h4><p>All you need to do is to install the <a href="https://marketplace.visualstudio.com/items?itemName=nivisi.dart-build-runner-tools">build_runner Tools</a> extension. After that, you will see 4 new commands in the context menu when you right click .dart files or folders:</p><ul><li><strong>Build / Watch <em>this</em></strong>: runs build_runner on the selected files. It simply maps relative paths of the selected files to build-filter params and launches build_runner. Must be ran on <em>generated</em> files like .g.dart.</li><li><strong>Build / Watch <em>parts</em></strong>: unlike the “<em>this</em>” command, it reads the selected files / folders and collects all the part directives. Must be run on files like admin.dart from the example above. The extension will automatically launch build_runner on the admin.g.dart and admin.freezed.dart files since it’s referenced in the source file itself.</li></ul><p>More examples and possible answers to your questions are in the extension’s description itself.</p><h4>That’s it folks!</h4><p>I couldn’t come up with a conclusion, so I’ll just put a philosophical statement here:</p><blockquote>Time is one of the most valuable things in this world. There are better ways to spend it rather than waiting for code generation to complete.</blockquote><p>Reach out to me in <a href="http://t.me/nivisi_feedback">Telegram</a> or join my <a href="https://t.me/nivisi_code">technical blog there</a>. I will be happy to have you.</p><p>Peace and light to your house.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7bca88fcb69" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Go and grow.]]></title>
            <link>https://nivisi.medium.com/go-and-grow-a3d6a004b181?source=rss-78ece1cfe53c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3d6a004b181</guid>
            <category><![CDATA[mindset]]></category>
            <category><![CDATA[challenge]]></category>
            <category><![CDATA[growth]]></category>
            <dc:creator><![CDATA[Nikita Sirovskiy]]></dc:creator>
            <pubDate>Mon, 30 Jan 2023 18:01:48 GMT</pubDate>
            <atom:updated>2023-01-30T18:01:48.239Z</atom:updated>
            <content:encoded><![CDATA[<h4>An occasional reminder: growth is there where you’re scared to go.</h4><p>Recently on the work I was given more responsibilities. I was happy. This was another step towards one of my personal goals. Couldn’t be better, right?</p><p>Although my body have met it with stress and fear. But… why? This is growth. It is definitely not a tragedy. It is a very good chance to learn a lot of new things. So why do I fear?</p><h4>Reason one, the fear of change.</h4><p>I can’t be sure, but that would be my dialogue with my body (the body goes first):</p><blockquote>— Hey boss, we’re quite good here where we are… Why to break the order of things?</blockquote><blockquote>— We’re going break things in order to grow. We’re going out of the comfort zone. Trust me, it will be alright.</blockquote><p>The comfort zone, yes. And this is normal. It is meant to protect us. Unfortunately this mechanism doesn’t always work as intended, but what can we do.</p><p>Well, we can just go and face the challenge. Just jump into the wild river, do our best and see what happens. You must trust yourself. You’ll learn how to do it. You’ll nail it. You’ll grow.</p><p>Be patient, be curious, learn from others. I bet that whenever you get new responsibilities there’s definitely someone around you who can mentor you during your learning period. A mentor can teach you by telling you their failures and showing the dos and don’ts.</p><p>Ask for help. Help requests must be met kindly. Everyone in your company must be interested in helping you doing your work better. If it is not about your company, then you should consider either switching your job or trying to change the atmosphere in your company.</p><h4>Reason two, the fear of evaluation</h4><p>In the depth of our mind we can be scared of evaluation. Even from our loved ones. We fear to be told we’re not as good as we think we are. Especially in such new things as a new role in the team.</p><p>We’re scared that if we fail the people around us will change their opinions. We fear to be fired.</p><p>This brings us to the comfort zone problem again:</p><blockquote>— Hey boss, the people around are so kind to us… But if we fail, they will know we’re an impostor. Let’s stay where we are as here we’re doing just great!</blockquote><blockquote>— We’ll learn how to do these new things greatly soon. Don’t worry.</blockquote><p>A new journey might be full of uncertainty, difficulties and stress. But that is okay. This is the way to grow.</p><p>Your company must be interested in your growth. It is a known fact that every person has gone through a learning process at some point in their life. So it’s fine to fail. Moreover, to fail is one of the best ways to learn. Remember the babies and how they learn to walk.</p><p>Don’t be afraid to ask for help. And don’t be afraid to grow.</p><p>Peace and light to your house.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3d6a004b181" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let them notice: delay your Futures in Flutter]]></title>
            <link>https://nivisi.medium.com/let-them-notice-delay-your-futures-in-flutter-6fa31f32d8c5?source=rss-78ece1cfe53c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6fa31f32d8c5</guid>
            <category><![CDATA[ux]]></category>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[user-experience]]></category>
            <category><![CDATA[future]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Nikita Sirovskiy]]></dc:creator>
            <pubDate>Fri, 20 Jan 2023 18:12:31 GMT</pubDate>
            <atom:updated>2023-01-21T21:04:21.657Z</atom:updated>
            <content:encoded><![CDATA[<h4>Our apps must be fast. But sometimes it makes sense to slow them down on purpose.</h4><p>We often use loaders to indicate when an API call or a long asynchronous operation is being executed. These loaders let the user know that they need to wait for the task to complete.</p><p>However, if the loader is shown and hidden too quickly, it can be confusing and frustrating for the user. To make the loaders more effective, we can add a slight delay before they are hidden.</p><p>Users need time to understand what’s happening.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QUzZk_j5fxD2Kc-6" /><figcaption>Photo by <a href="https://unsplash.com/@brett_jordan?utm_source=medium&amp;utm_medium=referral">Brett Jordan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Quick example, or why we are doing it</h3><p>Let’s pretend we have some cool pin page built with the power of the <a href="https://pub.dev/packages/pinput">pinput</a> package. When a user completes typing the pin code, we’ll verify it’s correct. If it’s not, we’ll show an error. Let’s do it!</p><p>The problem is that the verification process is very quick. Retrieving the pin code from local storage and confirming that it matches the user’s input is a swift task.</p><h4>Without delay</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*C0C3acer5AeI-W1FxoA6pw.gif" /><figcaption>The pin is verified without any delay.</figcaption></figure><p>The keyboard may be distracting the user from the main focus of the app, which is the pin dots. The result is not user friendly, because</p><blockquote>Users need time to understand what’s happening.</blockquote><h4>Let’s delay our verification</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*seitOFcdfmO-LCR5fRL58g.gif" /><figcaption>Some delay makes it more user friendly.</figcaption></figure><p>Neat.</p><ul><li>The keyboard has enough time to hide. Its animation won’t disturb the user from the pin animation.</li><li>The user has enough time to focus their eyes on the dots.</li><li>And enough time to observe that the dots have become lighter, indicating that the pin is being verified.</li></ul><h3>Let’s get to the code part</h3><p>Our verification method looks like this:</p><pre>Future&lt;void&gt; verify(String pin) async {<br>  /// Pretending to fetch from local storage ...<br>  await Future.delayed(const Duration(milliseconds: 100));<br><br>  if (pin != &#39;123456&#39;) {<br>    throw const FormatException();<br>  }<br>}</pre><p>And here’s our onSubmitted method:</p><pre>Future&lt;void&gt; onSubmitted(String pin) async {<br>  try {<br>    setState(() {<br>      // Making the pin go a bit lighter indicating that the pin is being verified.<br>      submittedColor = Colors.lightBlueAccent;<br>    });<br><br>    // Delaying the call 👇<br>    await Future.delayed(<br>      const Duration(milliseconds: 850),<br>      () =&gt; verify(pin),<br>    );<br><br>    // If no exception — we&#39;re good!<br>    setState(() {<br>      submittedColor = Colors.lightGreen;<br>    });<br><br>    await Future.delayed(const Duration(seconds: 1));<br><br>    // Navigate the user further ...<br>  } on Exception {<br>    shakeController.shake();<br><br>    setState(() {<br>      error = &quot;Pin is incorrect.&quot;;<br>      showError = true;<br>    });<br><br>    await Future.delayed(const Duration(seconds: 1));<br><br>    controller.text = &#39;&#39;;<br>    setState(() {<br>      showError = false;<br>      submittedColor = Colors.blue;<br>    });<br>  }<br>}</pre><p>We can use the same approach for any async operation during which we show loaders.</p><p>It may seem paradoxical, but when I press the ‘Save’ button, I expect the task to take at least a brief moment to complete. Simply showing me a success or error message and then navigating me away does not seem sufficient.</p><h4>That’s it, folks!</h4><p>Let me know what you think about it.</p><p>You can find the source code on <a href="https://github.com/nivisi/let_them_notice_arcicle">GitHub</a>.</p><p>Reach out to me in <a href="http://t.me/nivisi_feedback">Telegram</a> or join my <a href="https://t.me/nivisi_code">technical blog there</a>. I will be happy to have you there.</p><p>Peace and light to your house.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fa31f32d8c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Log like a Pro in Flutter with the power of mixins]]></title>
            <link>https://nivisi.medium.com/log-like-a-pro-in-flutter-with-the-power-of-mixins-10ebd110c06c?source=rss-78ece1cfe53c------2</link>
            <guid isPermaLink="false">https://medium.com/p/10ebd110c06c</guid>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[dartlang]]></category>
            <category><![CDATA[mixin]]></category>
            <category><![CDATA[maintenance]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Nikita Sirovskiy]]></dc:creator>
            <pubDate>Wed, 21 Dec 2022 14:35:57 GMT</pubDate>
            <atom:updated>2022-12-21T14:44:55.103Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p>Logging is one of the ways to understand how users use your app. It allows you to track important events like navigation and errors, handled and unhandled. Let’s see how you can log using mixins in Dart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*B1NXva19o1GAnB3Z" /><figcaption>Photo by <a href="https://unsplash.com/@chdwck9?utm_source=medium&amp;utm_medium=referral">Richard Dykes</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>What is logging?</h4><p>Logs could be just text messages:</p><pre>12:00:00 [I] App launch<br>12:00:00 [I] Home Screen opened<br>12:00:02 [I] Details Screen opened<br>12:00:02 [I] Receiving details for an item ...<br>12:00:03 [E] Unable to fetch the details of an item, here&#39;s why:<br>             *Exception details + Stacktrace*</pre><p>We can see two important things we achieve with logging:</p><ul><li>Reproduce users’ journey;</li><li>Inspect errors that occured. We can see where an error has occured and what were the technical details. When investigating problems, it is more useful than a note from a user «I opened the screen and the app just crashed!».</li></ul><h4>Logger library</h4><p>There are plenty of tools that we can use to log messages. If you search for a logger library on pub.dev you’ll find a lot of similar packages. prefer the <a href="https://pub.dev/packages/logger">logger</a> library.</p><p>It gives us the Logger class that we can use to write log messages:</p><pre>// Create it first<br>final log = Logger();<br><br>// Use it!<br>log.v(&quot;Verbose log&quot;);<br>log.d(&quot;Debug log&quot;);<br>log.i(&quot;Info log&quot;);<br>log.w(&quot;Warning log&quot;);<br>log.e(&quot;Error log&quot;);<br>log.wtf(&quot;What a terrible failure log&quot;);</pre><p>Here’s an example of what we’ll see in the console:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*9ITbWh_Abf6DsJmC4QVLYg.png" /><figcaption>Image from the logger’s <a href="https://pub.dev/packages/logger#output">README</a></figcaption></figure><p>Neat, isn’t it? Colors, formatting, etc. Logger gives you the power of configuring all of that by providing so called printers.</p><p>Personally I prefer simpler log messages. I’ll show it in a bit.</p><h4>Mixins &amp; Contextual logger</h4><p>We won’t use the logger library directly. Instead, we’ll use <a href="https://pub.dev/packages/contextual_logging">contextual_logging</a>.</p><p>Add it to your <strong>pubspec.yaml</strong>:</p><pre>flutter pub add contextual_logging</pre><p>contextual_logging provides us with a mixin we can attach to our classes. The mixin will bring the logging functionality to our class. Let’s say you have a controller and you want to track what’s happening inside of it.</p><pre>class MyController with <strong>ContextualLogging</strong> {<br>  Future&lt;void&gt; init() async {<br>    // Now you have access to the log object<br>    <strong>log</strong>.i(&#39;Initializing ...&#39;);<br><br>    await fetchSomeData();<br><br>    <strong>log</strong>.i(&#39;Initialized!&#39;);<br>  }<br>}</pre><p>In the console, once you call init, you’ll see these two messages:</p><pre>10.03.00 [I] MyController : Initializing...<br>10.03.01 [I] MyController : Initialized!</pre><h4>Anatomy of the message</h4><p>This message is formatted by the ContextualLogPrinter of the contextual_logging library. Checkout <a href="https://pub.dev/packages/contextual_logging#configuring-the-printer">this readme section</a> to learn how to configure it.</p><p>The anatomy is the following:</p><ol><li>Timestamp. It is the time when the message was written. Helpful when any logic in your app depends on time in any way;</li><li>Level. The Logger object gives us different log levels. This is for better understanding of a message: if it’s an info message, then it is most likely about the app’s behaviour. If it’s an error message, then it is for sure about an error that has occured;</li><li>Context. Most of the times it is the name of a class that has logged the message. It is unique per class (if classes have different names of). But it can be configured by overriding the logContext getter of the mixin. Learn more <a href="https://pub.dev/packages/contextual_logging#configuration">here</a>;</li><li>Message. It is the actual message that you pass to the log method. It is the behaviour: Screen opened, data fetched etc.</li></ol><h4>That’s it folks!</h4><p>This is a very basic example. In fact, with logging, you can do more. For example, write them to files that users will be able to share with you! Or you can redirect logs to an external logging tool. I’ll cover it in upcoming articles.</p><p>For now, you can checkout <a href="https://pub.dev/packages/contextual_logging#contextual_logging-pub-versionpub-version-imgpub-version-url">the docs</a> that show configuration of contextual_logging in more details.</p><p>Reach out to me in <a href="http://t.me/nivisi_feedback">Telegram</a> or join my <a href="https://t.me/nivisi_code">technical blog there</a>. I will be happy to have you there.</p><p>Peace and light to your house.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10ebd110c06c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tired of re-running Flutter code generation? Here’s how to do it with a shortcut in VS Code.]]></title>
            <link>https://nivisi.medium.com/tired-of-re-running-flutter-code-generation-heres-how-to-do-it-with-a-shortcut-in-vs-code-8f3fae216058?source=rss-78ece1cfe53c------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f3fae216058</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[tasks]]></category>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[code-generation]]></category>
            <dc:creator><![CDATA[Nikita Sirovskiy]]></dc:creator>
            <pubDate>Mon, 24 Oct 2022 07:21:39 GMT</pubDate>
            <atom:updated>2023-08-20T11:18:39.134Z</atom:updated>
            <content:encoded><![CDATA[<p>Code generation is a powerful tool. I love it. It can significantly decrease amount of boilerplate code you have to write.</p><p>With it, however, we must run terminal commands in order to make our app work. And the command is big: it’s boring to write it every time.</p><p>But VS Code is here to simplify our lives.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-FdghP-qnhCIF1G3" /><figcaption>Photo by <a href="https://unsplash.com/@bernardhermant?utm_source=medium&amp;utm_medium=referral">Bernard Hermant</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Basics</h4><p>The command that you have to run is the following:</p><pre>// To build it once<br>dart run build_runner build</pre><pre>// To «watch» for file changes and generate code on the go<br>dart run build_runner watch</pre><p>And if you want to delete the previously generated files, you need to add a parameter:</p><pre>dart run build_runner build --delete-conflicting-outputs <br>// Or<br>dart run build_runner watch --delete-conflicting-outputs</pre><p>Pretty big, huh? I wanted to avoid typing it again and again. There were two solutions for me:</p><ul><li>To have this command written in a notepad. I could then open it and copy the command, then insert it to the terminal;</li><li>In the terminal window, I could press the ↑ Up arrow and it would show me the command history. So I could “rerun” it from there. But it was not always a solution as in terminal I have been running other commands as well so sometimes the history was big.</li></ul><p>One more problem is that, from my experience, sometimes code generation doesn’t properly work until you run two more commands. I bet you know them.</p><pre># This one not only removes the temporary dependency files, but also erases the cache that generator creates:<br>flutter clean</pre><pre># Get dependencies again:<br>flutter pub get</pre><p>So usually I was just pressing ↑ Up arrow + Enter 3 times. It didn’t feel right.</p><h4>Create a VS Code task</h4><p>In VS Code, you can create so-called <a href="https://code.visualstudio.com/docs/editor/tasks">tasks</a>. Those are predefined commands that can be easily executed. For example, everytime before running your app. Or on a shortcut.</p><p>Let’s create our generator task.</p><p>Press ⌘Cmnd + ⇧ Shift + P. It will open the command palette. Select <strong>Tasks: Open User Tasks.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pv-nuQlJZnCc_-1FPAqr6w.png" /><figcaption>Command palette</figcaption></figure><p>If you don’t have any tasks configured yet, it might open another panel like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_i9TprR9UGH29ZrnIxF0-A.png" /><figcaption>This panel is opened after running <strong>Tasks: Open User Tasks</strong></figcaption></figure><p>Select <strong>Others</strong>. It must open a file called <strong>tasks.json:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kKT6993B8bNNg3IPvhQymg.png" /><figcaption>Just created <strong>tasks.json</strong> file</figcaption></figure><p>And now, we need to modify it by adding our task. Here it is. Copy it and insert it to the tasks array. I’ll explain the config later on.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f545ac44bf3416c5c384028ad3aec22b/href">https://medium.com/media/f545ac44bf3416c5c384028ad3aec22b/href</a></iframe><h4>Create a VS Code shortcut</h4><p>Now we need to bind that task to a shortcut.</p><p>Open <strong>Preferences</strong> → <strong>Keyboard Shortcuts</strong> → <strong>Open Keyboard Shortcuts (JSON)</strong> as in the GIF:</p><figure><img alt="Accessing keyboard shortcuts JSON file" src="https://cdn-images-1.medium.com/max/1024/1*uOLdG52wm4_er5YcMY_ymA.gif" /><figcaption>Opening keyboard shortcuts JSON</figcaption></figure><p>Now paste the following shortcut there:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7da77262e6ff42bafc7826df7a28f99e/href">https://medium.com/media/7da77262e6ff42bafc7826df7a28f99e/href</a></iframe><p>And save the file.</p><h4>Try it out!</h4><p>Now you can press ⌘ Cmnd + G in a Flutter project opened in VS Code and observe the result!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5rMtomXYALgIJ9ivmUPgUA.gif" /><figcaption>Code generation running with a shortcut</figcaption></figure><p>We’ve successfully ran the generator. Now we have a watcher running. It is to the right of the terminal window. If you want to terminate it, tap on it, focus the terminal window and press ⌃ control +C.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UF2zHPcZ241g68Pl5wYgGQ.png" /><figcaption>Result of code generation ran with a shortcut!</figcaption></figure><h4>If you</h4><h4>Conclusion</h4><p>This saves me a lot of time as I run code generation pretty often. But now it could be done in a second.</p><p>You can also configure it to run on app launch (when you press F5) before your app starts. So this way you will always regenerate the code before running the app.</p><p>Personally, I don’t find it’s convenient, so I better run it myself when I’d like to. That’s why this shortcut is a superhero for me.</p><p>Reach out to me in <a href="http://t.me/nivisi_feedback">Telegram</a> or join my <a href="https://t.me/nivisi_code">technical blog there</a>. I will be happy to have you there.</p><h4>Configuration of the task</h4><p>For more info of what and how can be configured in VS Code tasks, visit <a href="https://code.visualstudio.com/docs/editor/tasks">the official docs</a>.</p><p>Here’s my configuration explained:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/58765ea63c686724b902a4b56b06c4fa/href">https://medium.com/media/58765ea63c686724b902a4b56b06c4fa/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f3fae216058" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use Flutter Notifications to build your widgets]]></title>
            <link>https://nivisi.medium.com/how-to-use-flutter-notifications-to-build-your-widgets-c53686f5385f?source=rss-78ece1cfe53c------2</link>
            <guid isPermaLink="false">https://medium.com/p/c53686f5385f</guid>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[flutter-widget]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[notifications]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Nikita Sirovskiy]]></dc:creator>
            <pubDate>Wed, 19 Oct 2022 06:45:58 GMT</pubDate>
            <atom:updated>2022-10-19T06:45:58.658Z</atom:updated>
            <content:encoded><![CDATA[<p>Notifications — is a tool Flutter uses to pass any kind of data higher in the widget tree hierarchy. Somewhere in depth of your widget tree you can fire a notification and it will go up, like a bubble.</p><p><a href="https://api.flutter.dev/flutter/widgets/Notification-class.html">Here are the official docs</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PeLlEdnlDXdKAnxO" /><figcaption>Photo by <a href="https://unsplash.com/@barefootcommunications?utm_source=medium&amp;utm_medium=referral">Barefoot Communications</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4><strong>How can I use them?</strong></h4><p>If a notification is fired, you can “catch” it in the widget tree above by using a <a href="https://api.flutter.dev/flutter/widgets/NotificationListener-class.html">NotificationListener</a> widget. Remember the ScrollNotification class? Yep, that’s the kind of notifications we’re talking about.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d49c83ef85985b70a575fb56c2a660a7/href">https://medium.com/media/d49c83ef85985b70a575fb56c2a660a7/href</a></iframe><p>That onNotification callback takes a notification object as a parameter and require you to return a boolean. This boolean is an indicator whether the notification is allowed to keep going up in the widget tree.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8561f6adf25d3ea20a0369b0b797185b/href">https://medium.com/media/8561f6adf25d3ea20a0369b0b797185b/href</a></iframe><h4><strong>Can I define my own notifications?</strong></h4><p>Yes! All you need to do is to create a class and to extend it from the Flutter’s Notification class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a0d58e81e76595be99fcb34a8576534/href">https://medium.com/media/1a0d58e81e76595be99fcb34a8576534/href</a></iframe><p>Now you are able to dispatch your notifications using a BuildContext object:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4b7469911642134067ef464620a88cd6/href">https://medium.com/media/4b7469911642134067ef464620a88cd6/href</a></iframe><p>Parents of that widget can catch it up by using a NotificationListener:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9f585402889b6dc32e0ceb13e6c1594/href">https://medium.com/media/b9f585402889b6dc32e0ceb13e6c1594/href</a></iframe><h4><strong>How do I build the UI using it?</strong></h4><p>One of the ways is to use a NotificationListener in a StatefulWidget. You catch a notification, you update your state. Simple. Let’s use that MyNotification class that we’ve created.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed620ad28d5541874ff283ba1d6c76c1/href">https://medium.com/media/ed620ad28d5541874ff283ba1d6c76c1/href</a></iframe><p>Surely, we could just put that TextButton in the Column without defining a separate widget. But imagine that button is placed somewhere in the depth of the widget tree. In this case you should split your widgets into smaller ones. And this small example illustrates how you can use notifications to pass the data up in the tree.</p><h4><strong>But there’s another way…</strong></h4><p>Instead of creating stateful widgets or using change notifiers, we could use the <a href="https://pub.dev/packages/notification_builder">notification_builder</a> package. It gives us a builder callback. It is similar to onNotification in the NotificationListener, but is used to render the UI.</p><p>Let’s refactor our code above to use a NotificationBuilder:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d692b1863957ee2b88b5591412ea549c/href">https://medium.com/media/d692b1863957ee2b88b5591412ea549c/href</a></iframe><p>Neat. Now the NotificationBuilder is handling the state for us. So we don’t need to create a stateful widget ourselves.</p><p>However, under the hood, it works just in the way we implemented higher: it’s a stateful widget that uses a NotificationListener.</p><p>You can find the source code <a href="https://github.com/nivisi/notification_builder">on GitHub</a> a <a href="https://github.com/nivisi/notification_builder/blob/develop/src/example/">colorful example</a>.</p><h4><strong>Conclusion</strong></h4><p>Notifications is a good tool I discovered recently. Well, I definitely knew about notifications like ScrollNotification, but then I learned that we’re allowed to define our own notifications.</p><p>Now, instead of passing callbacks or ChangeNotifiers to the child widgets, we can use notification to pass the data up in the tree from the widgets below. Another way is to use an <a href="https://api.flutter.dev/flutter/widgets/InheritedWidget-class.html">InheritedWidget</a>… But it’s a different topic.</p><p>Reach out to me in <a href="http://t.me/nivisi_feedback">Telegram</a> or join my <a href="https://t.me/nivisi_code">technical blog there</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c53686f5385f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to learn programming or where to start to learn]]></title>
            <link>https://nivisi.medium.com/how-to-learn-programming-or-where-to-start-to-learn-337d611777ae?source=rss-78ece1cfe53c------2</link>
            <guid isPermaLink="false">https://medium.com/p/337d611777ae</guid>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[learning-and-development]]></category>
            <dc:creator><![CDATA[Nikita Sirovskiy]]></dc:creator>
            <pubDate>Mon, 05 Sep 2022 04:01:08 GMT</pubDate>
            <atom:updated>2022-09-05T04:01:08.084Z</atom:updated>
            <content:encoded><![CDATA[<h4>Your ideas is the best thing you can learn from. Or at least they are your reference point.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q13HQt6HvNcPKjI7wpg7Xw.jpeg" /></figure><p>In programming, I’ve never asked «what to do and where to start?». In fact, I didn’t really understand what I had to do (and even how to do it right). Also, I wasn’t very eager to get a job right away. I liked the process itself: you write commands and the computer executes them. Fantastic. And coming up with new ideas was no problem.</p><p>I learned how to come up with ideas when I was a kid. My favorite game was Wacraft 3. In it, you could create your own game modes. It even had a full-fledged programming language. You could create anything: game genres, interesting characters with their own skills or complex game systems.</p><p>The plan was the following: come up with something — try to implement it — if it did not work, look for it in the web — finish implementing it. There was not much information on the web, and I had to guess and learn at random. Or go to special forums. I must mention that this game had and has a remarkable community.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cJm4Xi1qrCmI33_v" /><figcaption>Photo by <a href="https://unsplash.com/ja/@brett_jordan?utm_source=medium&amp;utm_medium=referral">Brett Jordan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>When I got a little older I was sent to programming courses where we learned Pascal and Delphi. We had enough homework there, although sometimes I tried to code things myself. When they taught us how to draw, I figured out arrays for fun, so I could draw rain. And then, when we started using arrays in our programs, it was much easier for me.</p><p>Later on I started working with C# and WPF. It’s a framework for developing Windows applications. And it was the same thing: you come up with an idea — you try to implement it. When needed, search for help on the web. <em>How do you paint a button? How do you create and open a new window? How do you display data on the screen?</em> And so on.</p><blockquote>From recent examples: I got the idea to make an Android Launcher (home screen) using Flutter. It seemed to be something very complicated, but it turned out that’s it’s just a regular Flutter .</blockquote><blockquote>The source code, by the way, can be found <a href="https://github.com/nivisi/LeafyLauncher">here</a>.</blockquote><p>In one important area of my life, I kept making this mistake. I watched others, but didn’t try myself. Nothing good came out of it.</p><p>That’s because you learn much better with practice. You create something on your own, then improve and optimize it. You end up with something that works. That’s a great feeling.</p><p>If I just watched something on YouTube all the time without practicing, I wouldn’t really learn anything. That knowledge, gained mostly at random, helped me get a job. There I was lucky again: my boss turned out to be a really cool guy with a healthy attitude about development and processes. He taught me a lot.</p><p>By the way, if I started now I would upload all the code on GitHub. So I could show it off on interviews. Yeah, I’m a junior, but look, here’s what I can do. Guys like that are much more likely to be hired for training.</p><blockquote>Now I’m doing something simillar with this blog: learning on the go. I am sure there will be a lot of mistakes, but that’s the best way I can learn.</blockquote><p><em>This was the weekly Monday morning post. </em><a href="https://t.me/+SyTXDW7cljplMDFi"><em>Join in</em></a><em> so you don’t miss the next post.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=337d611777ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Context of communication for developers. Why is it important?]]></title>
            <link>https://nivisi.medium.com/context-of-communication-for-developers-why-is-it-important-c2931422090e?source=rss-78ece1cfe53c------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2931422090e</guid>
            <category><![CDATA[communication]]></category>
            <category><![CDATA[autonomy]]></category>
            <category><![CDATA[soft-skills]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[management]]></category>
            <dc:creator><![CDATA[Nikita Sirovskiy]]></dc:creator>
            <pubDate>Sun, 28 Aug 2022 20:12:44 GMT</pubDate>
            <atom:updated>2022-08-28T20:12:44.117Z</atom:updated>
            <content:encoded><![CDATA[<p>Each tool we use for development has its own communication context. GitHub — about code, Jira — about tasks and sprints, Confluence — about documentation, Figma — about designs, Slack — about announcements, communication and discussion, general issues.</p><p>Agree: it would be ridiculous to discuss in Figma the details of some PR from GitHub, and in Jira to make announcements for the team.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ni7rS7ZM93FNL34v" /><figcaption>Photo by <a href="https://unsplash.com/@mbaumi?utm_source=medium&amp;utm_medium=referral">Mika Baumeister</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Why to keep the context?</h4><p>It’s pretty easy to lose important discussions and decisions made. I agree: it is way faster to have a call in Slack rather than to chat in GitHub. But imagine the following.</p><p>Two developers are discussing the solution in a PR using direct messages on Slack. They both are sharing their ideas with each other, pointing out on existing and possible problems etc. All good, they came up with the best solution. They code it. The PR is merged. The ticket passes the QA and goes to production. Everyone is happy.</p><p>Though one day a new developer joins the team. They open a PR to solve a similar problem. The reviewer sees the same error as in the PR from the above.</p><p>As the discussion was in the direct messages, the reviewer cannot just copy the link to that discussion and write: we had a similar problem, here’s how we solved it. They need to either re-explain it, write the summary of that discussion or just copy the whole thing.</p><p>All that could have been avoided if the two had a discussion in the PR page initially. Or, at least, if they at least added a summary of their discussion to the PR page.</p><h4>Why Slack or any other messenger isn’t a silver bullet</h4><blockquote>(<em>to a programmer</em>) Have a look at this PR, please</blockquote><blockquote>(<em>to a designer</em>) Why don’t we have this button on this page?</blockquote><blockquote>(<em>to a manager</em>) This ticket is missing data, please fill it in.</blockquote><p>Sounds familiar?</p><p>In Slack, you often don’t turn your notifications off because you expect to get either something urgent or some announcement there. But often we get messages with review requests or questions about the task.</p><p>It is pretty convenient: you write a message, the addressee received a notification and in a minute he’s already responding. Yes, it is convenient. But not for the adresssee.</p><p>Not only the loss of context is a problem here, but also distraction. If a developer is coding, they are coding. They don’t want to interrupt and go to review someone else’s PR unless it is urgent.</p><h4>Then… How to ask for a review?</h4><p>In my first job, I was very lucky. We had a rule: <em>for a person to see the PR, just ask for a review on GitHub</em>. That’s it. There’s no need to ping in Slack. What for if we have notifications on GitHub? The exception was the urgency. Like, I’m blocked by this, let’s look at it and merge this PR?</p><p>And it was not just about GitHub. If I asked something in Figma, I wait for an answer there. Not getting it for a long time, I ask again. And only then, if I still don’t get an answer or I get blocked, I go to Slack. There I write:</p><blockquote>I asked in Figma, but got no answer, here’s a link to the question…</blockquote><p>After that, people usually start replying in Figma (or any other tool) more often. Having slowed down once or twice this way, I get a long-term bonus in the form of increased team autonomy.</p><h4>GitHub notifications and how not to miss them</h4><p>So it all works cool: I’ll review the code only when it’s convenient for me. And I won’t get disturbed by a notification on Slack or anywhere else. I will only receive a GitHub notification. But…</p><blockquote>With great power comes great responsibility 🕷</blockquote><p>The notification on GitHub is a blue circle on the bell at the top right of the screen. I don’t get an email (again, why clutter up the mail box?). It turns out that I can only find out that I’m asked to see a PR when I see this circle. And you may not open GitHub for a long time if you’re writing code.</p><p>It turned out to be an error for me. I don’t remember the point anymore, but I once let a team down by not looking at code or responding to questions on GitHub for a very long time.</p><p>To fix this, I set myself a reminder in TickTick for every hour, “check notification and email”. It was distracting at first, but it did the trick: I have built a habit. Now I check notifications many times a day whenever it suits me. At the beginning and end of the day, between tasks, before and after a break.</p><p>Think about each other. Before pinging your mate, ask yourself: is it that urgent so I need to Slack them? Can I wait until they have time to answer my questions? If the answer is no, use the corresponding tool and wait. They will respond soon.</p><p>Thus you will become more autonomous and more productive as a team.</p><p>If the team mixes up contexts, its communication may turn into the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xih4KdZ96DCMDLre" /><figcaption>Photo by <a href="https://unsplash.com/@ricardoviana?utm_source=medium&amp;utm_medium=referral">Ricardo Viana</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><em>It was a weekly post from my Telegram channel. </em><a href="https://t.me/+SyTXDW7cljplMDFi"><em>Join in</em></a><em> so you don’t miss the next post.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2931422090e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>