<?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 Crazelu on Medium]]></title>
        <description><![CDATA[Stories by Crazelu on Medium]]></description>
        <link>https://medium.com/@devcrazelu?source=rss-1e6027398518------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eG2vycIRM-jxQHICXb17JQ@2x.jpeg</url>
            <title>Stories by Crazelu on Medium</title>
            <link>https://medium.com/@devcrazelu?source=rss-1e6027398518------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 11:04:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@devcrazelu/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[Ringing the Terminal Bell]]></title>
            <link>https://medium.com/@devcrazelu/ringing-the-terminal-bell-70c7ea4f3f32?source=rss-1e6027398518------2</link>
            <guid isPermaLink="false">https://medium.com/p/70c7ea4f3f32</guid>
            <category><![CDATA[terminal-ui]]></category>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[serverpod]]></category>
            <dc:creator><![CDATA[Crazelu]]></dc:creator>
            <pubDate>Tue, 11 Aug 2026 20:43:53 GMT</pubDate>
            <atom:updated>2026-08-11T20:43:53.728Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L_PC9xLGePcKft1qS8mZ0w.png" /><figcaption>Image generated by GPT-5.6 Sol</figcaption></figure><p>I’ve had to work a lot with terminal UIs at <a href="https://serverpod.dev/">Serverpod</a> to power our agentic coding engine which is currently in <a href="https://serverpod.dev/blog/serverpod-4-public-beta">public beta</a>. And because we’re building a first class framework for Flutter and Dart, our TUIs are also written in Dart using a pretty nice library called <a href="https://pub.dev/packages/nocterm">nocterm</a>.</p><p>nocterm is still quite young, and so is the terminal UI space for Dart really, so we occasionally run into some issues that we tend to fix upstream to improve the library.</p><p>We received an internal report recently about the cursor not showing when the TUI is exited on iTerm2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kqx1GESz3plFS2_bvHBEQw.png" /></figure><p>The cursor can easily be restored using printf &#39;\e[?25h&#39; but it was still an inconvenient experience. This was something that no one else had reproduced using different terminals on macOS, Linux and Windows. So far, it is unique to iTerm2.</p><p>A quick triage pointed out a few inconsistencies in the way nocterm writes the OSC commands to restore colors before leaving alternate screen mode. Specifically, the commands were not terminated using either of BEL or ST control characters.</p><p>The fix is to just terminate those OSC commands with the BEL character — quite straightforward . I landed a <a href="https://github.com/serverpod/serverpod_tui/commit/7b47f3f4011a4f6e75356d6122590529d34fe8b2">quick fix</a> in our internal <a href="https://github.com/serverpod/serverpod_tui">serverpod_tui</a> library first and planned to upstream to nocterm.</p><p>While fixing this, I was very curious what BEL and ST meant so I did some digging and found something interesting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5EfBm5xUcSFSPr_z3aRdVw.png" /></figure><p>“Historically rings the terminal bell.” What is that?</p><p>Turns out modern terminals keep a feature that used to exist physically on electromechanical teleprinters. For instance, the Teletype Model 33 had a physical bell mechanism that was activated using BEL. The completion of a remote operation could be marked by physically ringing a bell to draw the attention of the operator without printing anything. CRT terminals kept the behaviour but replaced the the mechanical bell with electronics such that an audible ‘bell’ sound can be produced for BEL. ASCII standardized BEL at byte 0x07.</p><p>Modern terminals retain support for this protocol. Some terminals will display a flash instead of playing an audible sound. The script below produces a flash in the Mac Terminal.app when the system’s volume is reduced to 0 and produces an audible sound when volume &gt; 0.</p><pre>import &#39;dart:io&#39;;<br><br>void main() {<br>  stdout.write(&#39;\x07&#39;);<br>}</pre><p>You can also try this on Mac (and other POSIX-like shells) with printf &#39;\a&#39; instead of running a Dart script.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70c7ea4f3f32" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TheExcitingFlutterShow (EP 01)- UndoHistoryController and TextEditingController]]></title>
            <link>https://medium.com/@devcrazelu/theexcitingfluttershow-ep-01-undohistorycontroller-and-texteditingcontroller-6f011fd1c6db?source=rss-1e6027398518------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f011fd1c6db</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Crazelu]]></dc:creator>
            <pubDate>Mon, 26 Jun 2023 01:20:17 GMT</pubDate>
            <atom:updated>2023-06-26T01:26:52.452Z</atom:updated>
            <content:encoded><![CDATA[<h3>TheExcitingFlutterShow (EP 01)— UndoHistoryController and TextEditingController</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*08_YsY-ByqCgNILle_7Oqw.png" /></figure><p>Hey there internet wanderer! You made it to my little corner on the internet, again (or maybe for the first time).</p><p>*Inserts a warm friendly hug with gentle pats on the back.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FqRCXNcgACZ3aQqG1h6%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fstudiosoriginals-teddy-too-big-qRCXNcgACZ3aQqG1h6&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExYmFmNzViMmQzMTk3MmZmMGI3MmRjYmU3NDQ1MThkZjMzMTI2NTQ2ZSZlcD12MV9pbnRlcm5hbF9naWZzX2dpZklkJmN0PWc%2FqRCXNcgACZ3aQqG1h6%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="326" frameborder="0" scrolling="no"><a href="https://medium.com/media/524a1a59fef43c3d764fe5206dcfec2d/href">https://medium.com/media/524a1a59fef43c3d764fe5206dcfec2d/href</a></iframe><p>This is an experimental series where I delve into very well known (and less known) widgets, exploring their capabilities and sharing the exciting spoils I find.</p><p>You can find all the code written for this series on <a href="https://github.com/Crazelu/TheExcitingFlutterShow">GitHub</a>. If you prefer video content, this series is also available on <a href="https://youtu.be/Dt6zNyqcISw">Youtube</a>.</p><p>In this episode, I share some interesting features that you can use in your apps to create richer experiences for your users.</p><h3>First spoil— UndoHistoryController</h3><p>UndoHistoryController is a controller for the UndoHistory widget. UndoHistory is a widget that provides undo/redo capabilities for a ValueNotifier. It also has a low-level interface binding to platform specific implementations that listen to keyboard events to effect undo/redo actions.</p><p>From Flutter 3.0.0, you can now pass an UndoHistoryController to TextField. This is thanks to this <a href="https://github.com/flutter/flutter/pull/96968">pull request</a>. UndoHistoryController is a ValueNotifier that notifies attached listeners of changes in UndoHistoryValue.</p><p>For a very simple showcase, I’ll create an instance of UndoHistoryController, pass it to a TextField, listen to that instance using a ValueListenableBuilder and return a row on buttons in the builder to perform undo/redo operations.</p><pre>...<br>late final _undoController = UndoHistoryController();<br>...<br><br>TextStyle? get enabledStyle =&gt; Theme.of(context).textTheme.bodyMedium;<br>TextStyle? get disabledStyle =&gt;<br>      Theme.of(context).textTheme.bodyMedium?.copyWith(color: Colors.grey);<br>...<br><br>//...in the build method<br>Column(<br>          mainAxisAlignment: MainAxisAlignment.center,<br>          children: &lt;Widget&gt;[<br>            TextField(<br>              undoController: _undoController,<br>              maxLines: 4,<br>              decoration: const InputDecoration(<br>                border: OutlineInputBorder(<br>                  borderSide: BorderSide(<br>                    color: Colors.blueAccent,<br>                  ),<br>                ),<br>                enabledBorder: OutlineInputBorder(<br>                  borderSide: BorderSide(<br>                    color: Colors.blueAccent,<br>                  ),<br>                ),<br>              ),<br>            ),<br>            const SizedBox(height: 20),<br>            ValueListenableBuilder&lt;UndoHistoryValue&gt;(<br>              valueListenable: _undoController,<br>              builder: (context, value, _) {<br>                if (value == UndoHistoryValue.empty) return const SizedBox();<br>                return Row(<br>                  children: [<br>                    TextButton(<br>                      child: Text(<br>                        &#39;Undo&#39;,<br>                        style: value.canUndo ? enabledStyle : disabledStyle,<br>                      ),<br>                      onPressed: () {<br>                        _undoController.undo();<br>                      },<br>                    ),<br>                    TextButton(<br>                      child: Text(<br>                        &#39;Redo&#39;,<br>                        style: value.canRedo ? enabledStyle : disabledStyle,<br>                      ),<br>                      onPressed: () {<br>                        _undoController.redo();<br>                      },<br>                    ),<br>                  ],<br>                );<br>              },<br>            ),<br>          ],<br>        )</pre><p>Clicking the Undo and Redo buttons will remove and reapply changes from the TextField value respectively.</p><p>Web and desktop apps built with Flutter can take advantage of this with Shortcuts and Actions to associate certain shortcuts with actions that trigger undo/redo for text input.</p><p>Apart from using this on text input, you can wrap any interactive part of your app with UndoHistory widget and manage content update to UndoHistory’s stack. With an associated UndoHistoryController, you will be able to undo/redo other kinds of interactive input (for instance, strokes on a canvas for a drawing app).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F5qyEqSBsxQK4JbT8Gg%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FZion-Animations-5qyEqSBsxQK4JbT8Gg&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExNjNlZTdmOGM1ZWEyZDMxZmFmNTBiNzNlNTUxODUyNmQ0YmRhYzFhZiZlcD12MV9pbnRlcm5hbF9naWZzX2dpZklkJmN0PWc%2F5qyEqSBsxQK4JbT8Gg%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="243" frameborder="0" scrolling="no"><a href="https://medium.com/media/2905909e11eb3fa93690d0f7eb5934bc/href">https://medium.com/media/2905909e11eb3fa93690d0f7eb5934bc/href</a></iframe><blockquote>Catch your breath</blockquote><h3>Second spoil — TextEditingController</h3><p>Mobile apps typically receive inputs through user interaction. These inputs could be button clicks affirming a decision, text inputs representing user login details, etc.</p><p>TextField, TextFormField and EditableText (rarely used directly) are usually the go-to widgets for text inputs. These widgets each take a <a href="https://api.flutter.dev/flutter/widgets/TextEditingController-class.html">TextEditingController</a> which keeps track of the text value as it is updated by keyboard events.</p><p>For most app use cases, passing a single TextStyle for editable texts is sufficient. For chat apps, for example, it could be important to make visual distinctions between texts in a TextField by styling tagged usernames differently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qtx3dYEgEMZoCiREQCUXtA.jpeg" /></figure><p>Since TextFields take and apply just one style, we can’t specify a different style for the tagged user names directly. The first time I had to implement this feature, my first line of thinking was to read the source for TextField. I was hoping to see where this style is applied so I could write a modified TextField that takes another style and applies it to texts that match the pattern for tagged user names in the app.</p><p>After scrolling through 4000+ lines of code, I found <em>buildTextSpan</em>. There’s been some new additions to this method since the first time I found it. But where to focus is the last return statement.</p><pre>/// Builds [TextSpan] from current editing value.<br>  ///<br>  /// By default makes text in composing range appear as underlined.<br>  /// Descendants can override this method to customize appearance of text.<br>  TextSpan buildTextSpan() {<br>    if (widget.obscureText) {<br>      String text = _value.text;<br>      text = widget.obscuringCharacter * text.length;<br>      // Reveal the latest character in an obscured field only on mobile.<br>      // Newer versions of iOS (iOS 15+) no longer reveal the most recently<br>      // entered character.<br>      const Set&lt;TargetPlatform&gt; mobilePlatforms = &lt;TargetPlatform&gt; {<br>        TargetPlatform.android, TargetPlatform.fuchsia,<br>      };<br>      final bool brieflyShowPassword = WidgetsBinding.instance.platformDispatcher.brieflyShowPassword<br>                                    &amp;&amp; mobilePlatforms.contains(defaultTargetPlatform);<br>      if (brieflyShowPassword) {<br>        final int? o = _obscureShowCharTicksPending &gt; 0 ? _obscureLatestCharIndex : null;<br>        if (o != null &amp;&amp; o &gt;= 0 &amp;&amp; o &lt; text.length) {<br>          text = text.replaceRange(o, o + 1, _value.text.substring(o, o + 1));<br>        }<br>      }<br>      return TextSpan(style: _style, text: text);<br>    }<br>    if (_placeholderLocation &gt;= 0 &amp;&amp; _placeholderLocation &lt;= _value.text.length) {<br>      final List&lt;_ScribblePlaceholder&gt; placeholders = &lt;_ScribblePlaceholder&gt;[];<br>      final int placeholderLocation = _value.text.length - _placeholderLocation;<br>      if (_isMultiline) {<br>        // The zero size placeholder here allows the line to break and keep the caret on the first line.<br>        placeholders.add(const _ScribblePlaceholder(child: SizedBox.shrink(), size: Size.zero));<br>        placeholders.add(_ScribblePlaceholder(child: const SizedBox.shrink(), size: Size(renderEditable.size.width, 0.0)));<br>      } else {<br>        placeholders.add(const _ScribblePlaceholder(child: SizedBox.shrink(), size: Size(100.0, 0.0)));<br>      }<br>      return TextSpan(style: _style, children: &lt;InlineSpan&gt;[<br>          TextSpan(text: _value.text.substring(0, placeholderLocation)),<br>          ...placeholders,<br>          TextSpan(text: _value.text.substring(placeholderLocation)),<br>        ],<br>      );<br>    }<br>    final bool withComposing = !widget.readOnly &amp;&amp; _hasFocus;<br>    if (_spellCheckResultsReceived) {<br>      // If the composing range is out of range for the current text, ignore it to<br>      // preserve the tree integrity, otherwise in release mode a RangeError will<br>      // be thrown and this EditableText will be built with a broken subtree.<br>      assert(!_value.composing.isValid || !withComposing || _value.isComposingRangeValid);<br>      final bool composingRegionOutOfRange = !_value.isComposingRangeValid || !withComposing;<br>      return buildTextSpanWithSpellCheckSuggestions(<br>        _value,<br>        composingRegionOutOfRange,<br>        _style,<br>        _spellCheckConfiguration.misspelledTextStyle!,<br>        spellCheckResults!,<br>      );<br>    }<br>    // Read only mode should not paint text composing.<br>    return widget.controller.buildTextSpan(<br>      context: context,<br>      style: _style,<br>      withComposing: withComposing,<br>    );<br>  }<br>}</pre><p>Observe that building the text span is delegated to the attached TextEditingController when the TextField’s obscureText property is false and when no active composition is going. That, right there is the first spoil.</p><p>This discovery simplified my approach. I no longer had to modify the TextField (actually EditableText) widget directly. I only needed to use a custom TextEditingController with the <em>buildTextSpan</em> method overridden to style user tags differently.</p><p>I’m going to demonstrate this with a simpler example than user tags.</p><blockquote>Example use case: every word that matches “Flutter” exactly will be painted blue and bold.</blockquote><pre>class CustomEditingController extends TextEditingController {<br>  final RegExp _pattern = RegExp(r&quot;\Flutter&quot;);<br>  final TextStyle _customStyle = <br>        TextStyle(color: Colors.blue, fontWeight: FontWeight.bold);<br><br><br>  /// Builds [TextSpan] from current editing value.<br>  ///<br>  /// By default makes text in composing range appear as underlined. Descendants<br>  /// can override this method to customize appearance of text.<br>  @override<br>  TextSpan buildTextSpan({<br>    required BuildContext context,<br>    TextStyle? style,<br>    required bool withComposing,<br>  }) {<br>    assert(!value.composing.isValid ||<br>        !withComposing ||<br>        value.isComposingRangeValid);<br>    // If the composing range is out of range for the current text, ignore it to<br>    // preserve the tree integrity, otherwise in release mode a RangeError will<br>    // be thrown and this EditableText will be built with a broken subtree.<br>    final bool composingRegionOutOfRange =<br>        !value.isComposingRangeValid || !withComposing;<br><br>    // Only check for pattern matches when composition is not ongoing<br><br>    if (composingRegionOutOfRange) {<br>      // Find all matches<br>      final matches = _pattern.allMatches(text).toList();<br><br>      if (matches.isNotEmpty) {<br>        // Style matches with _customStyle<br>        // and other texts with the style passed into buildTextSpan<br>        List&lt;TextSpan&gt; children = [<br>          TextSpan(text: text.substring(0, matches.first.start))<br>        ];<br><br>        for (int i = 0; i &lt; matches.length; i++) {<br>          final match = matches[i];<br>          children.add(TextSpan(<br>            style: style?.merge(_customStyle),<br>            text: text.substring(match.start, match.end),<br>          ));<br>          if (i + 1 &lt;= matches.length - 1) {<br>            children.add(TextSpan(<br>              text: text.substring(match.end, matches[i + 1].start),<br>            ));<br>          } else {<br>            children.add(TextSpan(<br>              text: text.substring(match.end),<br>            ));<br>          }<br>        }<br><br>        return TextSpan(style: style, children: children);<br>      }<br><br>      return TextSpan(style: style, text: text);<br>    }<br><br>    final TextStyle composingStyle =<br>        style?.merge(const TextStyle(decoration: TextDecoration.underline)) ??<br>            const TextStyle(decoration: TextDecoration.underline);<br><br>    return TextSpan(<br>      style: style,<br>      children: &lt;TextSpan&gt;[<br>        TextSpan(text: value.composing.textBefore(value.text)),<br>        TextSpan(<br>          style: composingStyle,<br>          text: value.composing.textInside(value.text),<br>        ),<br>        TextSpan(text: value.composing.textAfter(value.text)),<br>      ],<br>    );<br>  }<br>}</pre><p>CustomEditingController overrides the <em>buildTextSpan</em> method to find strings that match the “Flutter” pattern and style them with the custom text style.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*4oW-JTE-x943udc83AzIdg.gif" /><figcaption>Custom editable text styling</figcaption></figure><p>Passing an instance of CustomEditingController to a TextField suddenly has this interesting effect as seen above. You can extend the capabilities of the CustomEditingController to style different kinds of texts if you’re building a rich text editor, for example. A practical use for this spoil can be found in the <a href="https://pub.dev/packages/fluttertagger">FlutterTagger</a> package I wrote for adding tagging abilities (user mentions, hashtags) to your Flutter app.</p><h3><strong>Wrapping Up</strong></h3><p>We have seen how to take advantage of the TextEditingController&#39;s text ‘painting’ capabilities on a high level to add visual distinction to the texts in TextField.</p><p>I have also demonstrated how UndoHistoryController can be used to implement a simple text editing interface with undo and redo actions.</p><p>That brings us to the end of this episode.<br>You can read the code for this episode on <a href="https://github.com/Crazelu/TheExcitingFlutterShow/tree/main/episode1">GitHub</a>.</p><p>Stay safe wanderer.<br>Catch you in the next one!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f011fd1c6db" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Secret Message Sharing App with Flutter — Part 3]]></title>
            <link>https://medium.com/@devcrazelu/building-a-secret-message-sharing-app-with-flutter-part-3-5d7ec82aa113?source=rss-1e6027398518------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d7ec82aa113</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[steganography]]></category>
            <dc:creator><![CDATA[Crazelu]]></dc:creator>
            <pubDate>Wed, 10 Aug 2022 23:03:38 GMT</pubDate>
            <atom:updated>2022-08-10T23:03:38.772Z</atom:updated>
            <content:encoded><![CDATA[<h3><a href="https://medium.com/@devcrazelu/building-a-secret-message-sharing-app-with-flutter-part-2-fb5e09cbcf61?source=your_stories_page-------------------------------------">Building a Secret Message Sharing App with Flutter — Part </a>3</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TxZAv-97GG_wgLmrBivDUw.png" /></figure><p>Hey there internet wanderer!</p><p>In the <a href="https://medium.com/@devcrazelu/building-a-secret-message-sharing-app-with-flutter-part-1-2fcc0b01cba6">first part</a> of this series, I introduced steganography and showed how secret messages — plain or encrypted — can be embedded in images. In <a href="https://medium.com/@devcrazelu/building-a-secret-message-sharing-app-with-flutter-part-2-fb5e09cbcf61">Part 2</a>, I demonstrated how to improve the security of the hidden messages by encrypting them symmetrically or asymmetrically.</p><p>This article builds upon knowledge of some terms and practices from the preceding articles in this series. I recommend reading the first two parts before continuing with this, if you haven’t done that already.</p><p>We’ve established the data hiding and encryption layer for our app to function. What’s left is to put the UI together, handle user authentication and add support for uploading images with captions and optional secret messages targeted at specific users.</p><p>So, let’s dive in!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3aGZA6WLI9Jde%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3aGZA6WLI9Jde%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F3aGZA6WLI9Jde%2F200.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="304" frameborder="0" scrolling="no"><a href="https://medium.com/media/bfd3c1f066c85bbbbbc175cf86e12c9c/href">https://medium.com/media/bfd3c1f066c85bbbbbc175cf86e12c9c/href</a></iframe><h3>Getting the UI ready</h3><p>This article is going to focus on the intricate parts of uploading and downloading images with secret messages along with the necessary optimisations put in place to enhance performance.<br>If you want to peek at the code for the rest of the UI, <a href="https://github.com/Crazelu/storiez">here</a>, knock yourself out.</p><p>Here’s a sneak peak of the UI😉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UHSKVS_KpeJm3SLmC8tOZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*snnhTVNfR1klhKkYX11Huw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dxSBLtFxLOzUIoK6gplq6A.png" /></figure><p>Here I employed my design sense and used a limited colour palette so I don’t have to worry so much about aesthetics but have pleasant results at the same time. Also, as you can see, I’ve decided to name the app <strong>Storiez</strong>.</p><h3>Authentication</h3><p>Since the initial concept of the app is to allow users share image stories with an option to add secret messages for other users of their choice, we need an auth system in place.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/349907dc83a64b42f85361989c5252b1/href">https://medium.com/media/349907dc83a64b42f85361989c5252b1/href</a></iframe><p>Signup and login are straightforward email and password auth operations using Firebase Auth. At the point of account creation, some additional data is generated and stored for that user. For example, a keypair containing public and private keys for asymmetric encryption is generated. The private key is stored locally while the public key is stored online along with the rest of the user’s supplied data on Firebase. This is necessary for sending secret messages later on so that the messages can only be encrypted with the publicly available public key and decrypted with the private key which never leaves the user’s device.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/56d06cccc545ae558a523705ce796ef4/href">https://medium.com/media/56d06cccc545ae558a523705ce796ef4/href</a></iframe><h3>Image Upload</h3><p>With authentication taken care of, the next thing to worry about is a database to upload images. I had initially used FirebaseStorage for this but eventually switched to Cloudinary because there were issues with uploading images to Firebase after some test uploads (I probably exceeded the bandwidth or something).</p><p>I wrote an ImageService class containing methods for uploading, downloading and deleting images with a temporary image cache to reduce the frequency of re-downloads from the internet.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d00bcfadd64fbf3d985bdcaedc811e1/href">https://medium.com/media/5d00bcfadd64fbf3d985bdcaedc811e1/href</a></iframe><h3>Story Creation</h3><p>A story on Storiez contains an image and an optional caption. The image may or may not contain a secret message. When it does, it’s targeted at a specific user on Storiez and only they will be able to view this message. For everyone else, they see the image but it’s oblivious to them that a secret message is hiding in there, somewhere.</p><p>Story creation follows the steps:</p><ul><li>User selects an image</li><li>User adds optional caption</li><li>User adds optional secret message</li><li>When a secret message is included, user must specify the recipient of that message</li><li>Image is uploaded to Cloudinary and URL retrieved</li><li>Story record (image url, the poster, upload time and an optional caption) is then sent to Firebase Cloud Firestore</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*8IKkqxb8o1OvPtDK35Ad3A.gif" /></figure><h4>Embedding secret message in image</h4><p>When a secret message is added and recipient selected, the message is encrypted with the recipient’s public key and the recipient’s id appended to the encrypted blob. This is so that on the recipient’s end, a match can first be made on the id appended to the encrypted blob before attempting to decrypt with the locally stored private key.</p><p>However, encoding the image with a secret message can be a very intensive task to perform and what I noticed was that it blocked other UI events from going through until it was done. If you’re familiar with the concept of Dart’s isolates, you’ll know that Flutter apps run in one Dart Isolate with an event loop which executes events from a queue. When you need to do intensive tasks that can block other UI events and cause your app to drop frames and introduce jank and lags, you’ll need to spawn another isolate so there’s no compromise on the smooth experience of your app.</p><p>This embedding and encryption is powered by <a href="https://github.com/Crazelu/steganograph"><strong>Steganograph</strong></a> — a pure Dart steganography package I wrote during the course of this series.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6a56ba8f6e29ff9188c7efe59a5e315/href">https://medium.com/media/f6a56ba8f6e29ff9188c7efe59a5e315/href</a></iframe><p>That was the case here. A new isolate was spawn and in it, the image was encoded with the secret message and then returned for upload to Cloudinary.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a421ff4c6b110333746da4557a37e5a0/href">https://medium.com/media/a421ff4c6b110333746da4557a37e5a0/href</a></iframe><p>With story creation and upload completed, what’s left is listening to a stream of stories and showing secrets to target recipients.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl4EpjiFPRJrPfkY7K%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl4EpjiFPRJrPfkY7K%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="326" frameborder="0" scrolling="no"><a href="https://medium.com/media/015fdc7edbda0a9faf7448882f07ab33/href">https://medium.com/media/015fdc7edbda0a9faf7448882f07ab33/href</a></iframe><h3>Showing Stories and Secrets</h3><p>Since Storiez uses Firestore, we have access to a stream of records directly. For each story, we get:</p><ul><li>image url</li><li>optional caption</li><li>poster</li><li>upload time</li></ul><p>To determine whether there’s a secret for the current user (viewer) in any story, the image is first dowloaded using the image url in the story and then decoded with <a href="https://github.com/Crazelu/steganograph"><strong>Steganograph</strong></a>. If any textual data is returned from that operation, it’ll have two parts: an unencrypted recipient id and an encrypted blob containing the secret message.</p><p>The recipient id is first compared to the current user’s (viewer) id and if there’s a match, it indicates they are the recipient of the secret message. So their private key is fetched from local storage and then used to decrypt the encrypted blob. This doesn’t provide any room for exploitation in case you’re wondering because even if the recipient id was tampered with after the secret message has been encoded with a public key that doesn’t belong to the recipient with that id, they won’t be able to decode the secret message anyway.</p><p>Just like encoding an image with a secret message can be an intensive operation that impacts performance, decoding carelessly can cause your app to drop frames too. Also, decoding will happen more frequently than encoding since users will likely swipe more to view other stories than they would upload. So, the UI shouldn’t be blocked at all during those swipe transitions while the decoding is going on in the background.</p><p>Again, a new isolate is spawned to handle that task. A SecretCache caching utility is also introduced to temporarily hold viewed secrets so there’s no need to decode images all over again until the app loses that state.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/861cd03f55f6d4624acbb4051b9b00ff/href">https://medium.com/media/861cd03f55f6d4624acbb4051b9b00ff/href</a></iframe><p>If a secret message is found in any image, an eye icon shows up at the top of that story so the user can view the secret.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*xws89VpYh2bwCx2U9nFrpw.gif" /></figure><h3>That’s a wrap?</h3><p>Not quite!</p><p>As with other stories applications, we want posts on Storiez to be short lived. After 24 hours, if they haven’t been deleted by the poster, they are auto deleted.</p><p>Since the stories are uploaded to Firebase, one way to implement this auto deletion would be to setup a server with a CRON job which executes a cloud function to delete expired stories.</p><p>Yea, I didn’t wanna do that.<br>Instead, every 30 seconds, a story deletion job is run while the app is active to handle this. This is also plugged to the stories stream listener so expired stories are deleted immediately on app launch without waiting for the next deletion interval.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5411bb542bad745de7e6eac14eb5454c/href">https://medium.com/media/5411bb542bad745de7e6eac14eb5454c/href</a></iframe><p>To make this work, when you upload stories, their ids are stored locally along with their upload times so some lookup can be done in the deletion job to find the story and then find out if it has expired.</p><h3>Now that’s a wrap!</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F5nG5kIv4o5fPHKD7wU%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F5nG5kIv4o5fPHKD7wU%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F5nG5kIv4o5fPHKD7wU%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="326" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1346a8d5e144a17464973be50aef29a/href">https://medium.com/media/b1346a8d5e144a17464973be50aef29a/href</a></iframe><p>There you have it. A secret message sharing app built with Flutter and Dart leveraging steganography and encryption.<br>If you want to take a look at the entire code or just play with the app, you can find <a href="https://github.com/Crazelu/storiez">Storiez on GitHub</a>.</p><p>You’ve made it to the end of this series. I hope you enjoyed this as much as I enjoyed putting it together. Do leave your thoughts and comments. <br>Cheers and keep wandering the internet!👍🏾</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d7ec82aa113" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Secret Message Sharing App with Flutter — Part 2]]></title>
            <link>https://medium.com/@devcrazelu/building-a-secret-message-sharing-app-with-flutter-part-2-fb5e09cbcf61?source=rss-1e6027398518------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb5e09cbcf61</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[steganography]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Crazelu]]></dc:creator>
            <pubDate>Mon, 30 May 2022 15:42:26 GMT</pubDate>
            <atom:updated>2022-08-10T23:19:22.735Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a Secret Message Sharing App with Flutter — Part 2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jzjZdP0kRxhP8Rut_SFBVA.png" /></figure><p>Hey there internet wanderer!</p><p>In the <a href="https://medium.com/@devcrazelu/building-a-secret-message-sharing-app-with-flutter-part-1-2fcc0b01cba6">previous part</a>, I introduced you to steganography and showed you how secret messages — plain or encrypted — can be embedded in images.</p><p>This article assumes you already know about steganography, PNG tEXt chunk, and symmetric encryption using <a href="https://github.com/Crazelu/igodo">Igodo</a>. I recommend reading the <a href="https://medium.com/@devcrazelu/building-a-secret-message-sharing-app-with-flutter-part-1-2fcc0b01cba6">first part</a> before continuing with this, if you haven’t done that already.</p><p>I also pointed out a drawback to using symmetric encryption especially for our use case. With the secret message sharing app, users will be able to upload images as their stories and hide messages for specific users. Symmetric encryption opens a pathway for exploitation because the secret message has to be encrypted and decrypted with the same key. This means there has to be a way to pass the same encryption key from the sender to the recipient in order for them to find the real message. And that means would ideally be over an internet connection.</p><p>Hence, if someone else found this key by monitoring network requests and the payloads, all encrypted data can be decrypted. Yea, the message won’t be a secret anymore and this wouldn’t be a fun project.</p><p>However, this can be remedied with asymmetric encryption. In asymmetric encryption, cryptography is used to generate two different but related keys that can be used for encryption and decryption. Typically, a public and private key pair is generated. The message is encrypted with the public key which can be shared anywhere on the internet because the private key cannot be generated from it. On the receiver’s end, the incoming message is decrypted with the private key.</p><p>With this technique, the private key can remain on the owner’s device while the public key is shared for whenever anyone needs to send them a secret message. This is the same principle (although in its most basic form) used to encrypt messages on WhatsApp and even for blockchain use cases.</p><p>There are many asymmetric encryption <a href="https://cryptography.io/en/latest/hazmat/primitives/asymmetric/index.html">algorithms</a> available but for this series, I have chosen <a href="https://en.wikipedia.org/wiki/RSA_(cryptosystem)">RSA</a>. I have also found a <a href="https://pub.dev/packages/crypton">Dart package</a> with an implementation of this algorithm along with key pair generation logic.</p><h4>Updating the code</h4><p>I have cleaned up the codebase from the last part. The encode method no longer returns a list of integers representing the resulting image in bytes. Instead, it writes to a file and returns it. The output file path may be specified but a unique path in the same directory as the input file will be created if no output file path is specified or an invalid one was supplied.</p><p>Also, an enum <strong>EncryptionType </strong>is introduced to allow specification of what kind of encryption to be done — symmetric (in which case, <a href="https://github.com/Crazelu/igodo">Igodo</a> will be used) or asymmetric (RSA).</p><p>First, the encryption logic is extracted to a different method to handle both symmetric and asymmetric options.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/379ddcaa9b29231a1128a6f649c81cfe/href">https://medium.com/media/379ddcaa9b29231a1128a6f649c81cfe/href</a></iframe><p>The RSA keypair containing the public and private keys is generated using the C<a href="https://pub.dev/packages/crypton">rypton</a> dependency.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/52080cf0e532ce2630bb181790a5fda9/href">https://medium.com/media/52080cf0e532ce2630bb181790a5fda9/href</a></iframe><p>Now we can take a look at the modified <strong>encode</strong> method. If encryption type is asymmetric, the encryption key is decoded as an RSA public key and used to encrypt the message. The message is then written to the tEXt chunk of the resulting PNG image which is in turn written into an output file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/122bb43281311a791d5d7402a7505d71/href">https://medium.com/media/122bb43281311a791d5d7402a7505d71/href</a></iframe><p>Decryption also happens similarly. The encryption type is specified and depending on what that is, the message is either decrypted symmetrically using Igodo or asymmetrically using an RSA private key.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de8803b6a2498dba35e5be790d9fb5bb/href">https://medium.com/media/de8803b6a2498dba35e5be790d9fb5bb/href</a></iframe><p>The <strong>decode</strong> method now takes an extra encryptionType argument for — you guessed it — specifying what kind of decryption to be done.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3ffff30e28caa5601241e6daa5eb3749/href">https://medium.com/media/3ffff30e28caa5601241e6daa5eb3749/href</a></iframe><h4>Voilla</h4><p>Now we have support for symmetric and asymmetric encryption. We could use both for even greater security.</p><p>In the next part, I’ll show you how this steganographic magic can be brought to life with some real world use case — the secret message sharing Flutter app. Users will be able to share images on their stories (WhatsApp style) and have an option to hide secret messages for specific users.</p><p>The code from this series now lives in a Dart package that you can find on <a href="https://github.com/Crazelu/steganograph">GitHub</a> so you can read more granular implementation details.</p><p>That’s all for now. See you in the <a href="https://medium.com/@devcrazelu/building-a-secret-message-sharing-app-with-flutter-part-3-5d7ec82aa113">next part</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb5e09cbcf61" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Secret Message Sharing App with Flutter — Part 1]]></title>
            <link>https://medium.com/@devcrazelu/building-a-secret-message-sharing-app-with-flutter-part-1-2fcc0b01cba6?source=rss-1e6027398518------2</link>
            <guid isPermaLink="false">https://medium.com/p/2fcc0b01cba6</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[steganography]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Crazelu]]></dc:creator>
            <pubDate>Sun, 29 May 2022 20:11:36 GMT</pubDate>
            <atom:updated>2022-08-10T23:19:48.170Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a Secret Message Sharing App with Flutter — Part 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SY4GwoNzoCYxnTDPQew9kQ.png" /></figure><p>Hey there internet wanderer!</p><p>In this multi-part series, I share with you how you can leverage steganography, encryption and cryptography to build a secret message sharing app with Flutter.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FL2qukNXGjccyuAYd3W%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fcbc-schitts-creek-L2qukNXGjccyuAYd3W&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExM3NzOXdkejU4cTB3ZXQ2bDV4NHV5dzk3aGZidmYzMnh6N3pndWk2YSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FL2qukNXGjccyuAYd3W%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/af980c3295f64f818c60ebcfc20c6aa3/href">https://medium.com/media/af980c3295f64f818c60ebcfc20c6aa3/href</a></iframe><p>If you just went “what is stega… steganography?”, I’ll explain that in a moment.</p><p>Steganography is a practice of hiding secret data in an ordinary file in order to avoid detection. This ordinary file can be viewed by anyone that has access to it without any knowledge of some secret data unless they have the means to extract such data.</p><p>Think of it like hiding some secret message in plain sight — in your regular images you upload to the internet, text files you share back and forth with people, etc.</p><p>This secret message may be encrypted to provide additional security and so only the recipient with the right key can decrypt and find the real content. This is all without altering the presentation of the file. In the case of images, which this series will be based on, the RGBA channels are unaltered. So you sneak some secret in without compromising image quality and without messing with some pixels.</p><p>I first learnt about steganography when a friend posted something about it on their WhatsApp story in 2021. As a curious Computer Science major, I did some research and eventually started reading specifications of image formats for <a href="https://www.w3.org/TR/PNG/">PNG</a> and <a href="https://www.w3.org/Graphics/JPEG/itu-t81.pdf">JPEG</a>.</p><p>I paid more attention to PNG since I learnt about the <a href="https://www.w3.org/TR/PNG/#11tEXt">tEXt chunk</a> which allows textual data (typically used for image meta data) to be included.</p><blockquote>PNG provides the <a href="https://www.w3.org/TR/PNG/#11tEXt"><strong>tEXt</strong></a>, <a href="https://www.w3.org/TR/PNG/#11iTXt"><strong>iTXt</strong></a>, and <a href="https://www.w3.org/TR/PNG/#11zTXt"><strong>zTXt</strong></a> chunks for storing text strings associated with the image, such as an image description or copyright notice.</blockquote><h4>And… roadblock🤦</h4><p>The readAsBytes() method of the dart:io.File object return a list of integers representing the bytes in that file.<br>Since I was working with images, these bytes have to first be decoded using an appropriate decoder for the image format before any steganographic magic could be performed. I didn’t realise that and was messing with the bytes directly which in turn altered the structure the image format’s decoder expected. Hence, the resulting file would not be identified as a viewable image.</p><h4>Introducing the <a href="https://pub.dev/packages/image">Image</a> package</h4><p>I found a Dart package with loads of encoders and decoders along with transforms that can be done on images and this was perfect. Also, this package supports writing textual data to the PNG’s tEXt chunk.</p><p>Writing these encoders and decoders from scratch can be nightmarish. So after evaluating the complexity, I didn’t think to reinvent the wheel — if I did it’d be for more bragging rights.</p><p>The image package is used to decode PNG and JPEG files, write the textual data and then encode resulting bytes as PNG since I’ve found only PNG to have chunks for textual data at the time of writing this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37e66498f845a0cab12c3de4401184a3/href">https://medium.com/media/37e66498f845a0cab12c3de4401184a3/href</a></iframe><p>The resulting list of integers can then be written into a file with a .png extension to view the image — unaltered, except now there’s a hidden message.</p><p>Decoding and extracting the hidden message is as you can also imagine.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/442a536de1c701e9e04ce5ca956ec7a7/href">https://medium.com/media/442a536de1c701e9e04ce5ca956ec7a7/href</a></iframe><p>If a message was hidden in the image, it’ll be returned from the method.</p><p>There! Straightforward, yea?</p><p>This works but anyone can read the hidden message if they know how to decode PNG (and that’s one Google search away). So to truly make this message a secret, it can be encrypted before being written into the tEXt chunk.</p><h4>Encryption🔒</h4><p>Fortunately, I’ve experimented with encryption and have written a symmetric encryption algorithm sometime in the past which I called <a href="https://github.com/Crazelu/igodo">Igodo</a> (Igbo for “lock/key”).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8103a49080fae1770e6f35b4c7055408/href">https://medium.com/media/8103a49080fae1770e6f35b4c7055408/href</a></iframe><p>Now the message will be encrypted before being embedded if an encryptionKey is present. This means that upon decoding, if an incorrect or no encryption key is passed, the true message will not be found.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc44af91a4f8a7e22ac26e5d8b5c903e/href">https://medium.com/media/bc44af91a4f8a7e22ac26e5d8b5c903e/href</a></iframe><h4>And… we’re ready 🥳</h4><p>The setup is complete and works for our use case.</p><p>The a drawback to using symmetric encryption for this purpose is that we need to share this same key from the sender to the recipient to be able to decrypt the message. This wouldn’t be ideal for our secret message sharing app as that provides a room for exploitation. Since this encrypted data and key can be found by someone with malicious intent, they’ll be able to decode everything that was encrypted with that key.</p><p>To solve this, in the next part, I’ll share with you how we can improve on this using asymmetric encryption techniques where two keys are created — a private and public one. And only the public one is ever shared.</p><p>See you in the <a href="https://medium.com/@devcrazelu/building-a-secret-message-sharing-app-with-flutter-part-2-fb5e09cbcf61">next part</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2fcc0b01cba6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vanilla State Management in Flutter]]></title>
            <link>https://medium.com/@devcrazelu/vanilla-state-management-in-flutter-a359dbc77752?source=rss-1e6027398518------2</link>
            <guid isPermaLink="false">https://medium.com/p/a359dbc77752</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[state-management]]></category>
            <dc:creator><![CDATA[Crazelu]]></dc:creator>
            <pubDate>Mon, 25 Oct 2021 14:47:19 GMT</pubDate>
            <atom:updated>2021-10-26T08:23:03.455Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Vanilla state management in Flutter" src="https://cdn-images-1.medium.com/max/1024/1*hDazHjYxoeRhWwjHiz2dPA.jpeg" /></figure><p>Hey there internet wanderer!</p><p>If you’re reading this, chances are you’re a Flutter developer who has built apps with a handful of the existing state management libraries and solutions available on <a href="http://pub.dev/">pub.dev</a>. Maybe you have also engaged in the touchy argument about which solution is best.</p><p>That’s adorable (hehe). No, really.</p><p>In this article, I show you a simple way to manage your app’s state that doesn’t tightly couple business logic with UI, is testable and requires no third party dependency (yes, that’s what vanilla means innit?).</p><h4>The setup</h4><p>Our setup for this is going to follow a very simple stripped MVC approach.<br>We’ll use a controller which is tightly coupled with the view. However, this can be decoupled by creating an internal constructor for the controller and accessing it as a singleton object.</p><p>And yes, we’ll be rewriting the simple counter app that’s generated when a Flutter app is created. The MyHomePage has been renamed to HomeView. It’s no longer stateful and the increment method has also been removed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*-woFL15Nzb61RI2XRmGAnQ.png" /><figcaption>Folder Structure</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/830c24f6e20ed06f0109407cee4f19a7/href">https://medium.com/media/830c24f6e20ed06f0109407cee4f19a7/href</a></iframe><h4>The Controller</h4><p>The controller is just going to be a Listenable which can be listened to from the UI side for changes that update the view. A common example is the ChangeNotifier and that’s what we’ll be using in this demo.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a76abd1c9478ca109740b9ef88a528d/href">https://medium.com/media/3a76abd1c9478ca109740b9ef88a528d/href</a></iframe><p>Now let’s take a look at the HomeView</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eff663612caacf995a9d9de8088c0977/href">https://medium.com/media/eff663612caacf995a9d9de8088c0977/href</a></iframe><p>The HomeView is now a stateless widget and the part that requires rebuilds is wrapped with a ReactiveWidget. This is going to be performant because only that part of the widget tree will be rebuilt when there are changes.</p><p>The FloatingActionButton’s onPressed triggers the CounterController’s increment method which increments the count and notifies the UI.</p><pre>void increment() {</pre><pre>_count++;</pre><pre>notifyListeners();</pre><pre>}</pre><p>ReactiveWidget is essentially an AnimatedWidget that triggers its builder method whenever a change is observed in its controller. This controller is required to be a Listenable.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/15f83cd76337ded69810f3230ed2b0da/href">https://medium.com/media/15f83cd76337ded69810f3230ed2b0da/href</a></iframe><p>There you have it!<br>Production-app worthy state management without any dependency.</p><p>If you’d like to give this a try, clone the <a href="https://github.com/Crazelu/vanilla-flutter">repository</a> and have fun!</p><p>Ciao.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a359dbc77752" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s a Build Custom Flutter Dialog Handler]]></title>
            <link>https://medium.com/@devcrazelu/lets-a-build-custom-flutter-dialog-handler-feeb6e2acbf3?source=rss-1e6027398518------2</link>
            <guid isPermaLink="false">https://medium.com/p/feeb6e2acbf3</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-ui]]></category>
            <dc:creator><![CDATA[Crazelu]]></dc:creator>
            <pubDate>Wed, 18 Aug 2021 14:05:02 GMT</pubDate>
            <atom:updated>2021-08-18T14:16:04.287Z</atom:updated>
            <content:encoded><![CDATA[<h3>Let’s Build a Custom Flutter Dialog Handler</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5IOAX2sNo1ZH_PQWL7fMHw.jpeg" /></figure><p>Hey there, builder!</p><p>In this article I go over how dialogs for my projects are architected.</p><p>If you’ve ever needed a way to show dialogs from your view models or controllers without having to pass a BuildContext object around, or you just want to read some cool Flutter related stuff, then this article is for you.</p><h3>Why do we need custom dialog handlers in Flutter?</h3><p>The Flutter framework packs a lot of standard UI tools out of the box which are stable for use in production code and these follow recognized design patterns (Material, Cupertino).</p><p>However, dialogs are purely UI staples. What I mean is dialogs are views. They are composed of widgets and are ideally triggered after evaluating the results of some business logic. What this means for Flutter is that dialogs are, by default, designed to be called from views. I’m sure the showDialog method comes to mind now.</p><p>What then happens when our business logic is separated from our view and we need to `showDialog`?</p><p>One way would be to pass the BuildContext object from the view to the business logic abstraction and this invites us to write sloppy code as we’ll be writing the view for the dialog inside the business logic abstraction as well.</p><p>This makes it difficult to test the showOurDialog function because we’ll need a BuildContext object for that.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/03e3ebfcbec3761c1b688a6fefcb5b2e/href">https://medium.com/media/03e3ebfcbec3761c1b688a6fefcb5b2e/href</a></iframe><h3>Ok where’s the cool stuff?</h3><p>To show dialogs anywhere in your Flutter app without having to pass a BuildContext requires some basic setups — boilerplate code, if you will.</p><p>First we’ll need a model class to encapsulate the data our dialogs are going to need. Let’s call this model DialogRequest.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e64e20eacf94b37f8a36a254365e00cd/href">https://medium.com/media/e64e20eacf94b37f8a36a254365e00cd/href</a></iframe><p>Next, we create a DialogHandler which we’ll use to do such things as triggering showDialog and dismissing dialogs as well. This DialogHandler will hook with a DialogManager where we’ll register the methods for showing and dismissing a dialog.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab711cd4edb67f6ebb4967d7e1c2e256/href">https://medium.com/media/ab711cd4edb67f6ebb4967d7e1c2e256/href</a></iframe><p>The DialogHandler uses a Completer for asynchronous operations.</p><p>The method signatures which begin with ‘register’ will be called in the DialogManager where the actual UI code for the dialogs will reside.</p><p>So whenever we want to show a dialog, we bother only with the DialogHandler.</p><p>To be able to access a singular instance of this DialogHandler, we’ll register the handler as a lazy singleton using <a href="https://pub.dev/packages/get_it/install">GetIt</a>, a service locator.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d150f6dac41b3bdb345885abbcd0895/href">https://medium.com/media/0d150f6dac41b3bdb345885abbcd0895/href</a></iframe><p>Don’t forget to call setUpLocator before runApp.</p><p>Next, we write the UI logic for showing and dismissing dialogs with overlay entries in the DialogManager and register those methods with the DialogHandler.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/878c42d67fc294a93b119e7e09afa198/href">https://medium.com/media/878c42d67fc294a93b119e7e09afa198/href</a></iframe><p>And the FloatingDialogCard…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b5112ef8bcf428547e3a25491ab3e5f2/href">https://medium.com/media/b5112ef8bcf428547e3a25491ab3e5f2/href</a></iframe><p>For dialogs to be shown on any parent widget passed down from every route, the DialogManager needs to wrap around each of those individual parent widgets. There’s an easy way to do this! In your MaterialApp, add a builder property like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d32975e9497254e1b31b4a458819244f/href">https://medium.com/media/d32975e9497254e1b31b4a458819244f/href</a></iframe><p>Now every widget passed down from navigation routes will automatically be wrapped with a DialogManager so we can show our custom dialogs.</p><p>This concludes our setup.</p><p>Having done that, we can now trigger dialogs from our business logic abstractions and anywhere else you might want to trigger dialogs in your code without passing a context around.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/31ed3e3504781b15cec6bd33fab43760/href">https://medium.com/media/31ed3e3504781b15cec6bd33fab43760/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mMgzZ9eWTy2vvWJmvHPL0A.jpeg" /></figure><p>There you have it!</p><p>A very great advantage to showing dialogs this way is that you can have different kinds of dialogs, create a DialogType enum to represent the available options, and pass that down to the showDialog method and have the DialogManager display the appropriate widget for each enum value.</p><p>You can even go as far as including customized loaders and progress indicators.</p><p>If you’d like to go see a full working example with an extra kind of dialog, check out my <a href="https://github.com/Crazelu/flutter-dialog">flutter_dialog repository</a>.</p><p>I hope you enjoyed reading this as much as I enjoyed putting all of it together, and maybe you’ll try it in your own projects. I’m open to questions and suggestions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=feeb6e2acbf3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MySario Log[1]: Introducing MySario ]]></title>
            <link>https://medium.com/@devcrazelu/mysario-log-1-introducing-mysario-4a5efb232640?source=rss-1e6027398518------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a5efb232640</guid>
            <category><![CDATA[students]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Crazelu]]></dc:creator>
            <pubDate>Thu, 12 Aug 2021 00:04:20 GMT</pubDate>
            <atom:updated>2021-08-12T00:16:40.953Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>MySario (noun): a personalized class manager with a kink</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9A35Es8e8nv9hP8Tqwl0Ng.jpeg" /></figure><p>Hey there, internet wanderer!</p><p>You guessed it!</p><p>We got rid of our placeholder name, SpaceApp, and chose MySario for some interesting reasons.</p><p>We are building a personalized class manager for present day students who love to catch cruise as much as they love (if not more) real-time school event updates and announcements.</p><p>MySario was coined from impresario which means a person who organizes (often concerts and shows).</p><p>In our case, MySario is a personalized fun guy with a proud face emoji that manages your class, delivers important and cruise messages, and reminds you to attend your school events so you can focus on more important things like not dropping out and making schmoney.</p><p>We considered names like:</p><ul><li><em>Klasapp </em>because Samuel thought it was cool👀</li><li><em>Chóros</em> which is Greek for space</li><li><em>Fiton </em>— Munachi’s genius creation which is an inversion of Notify. Smart right?</li><li><em>LutoHub</em> — derrived from “Lucky” and “Tobe” because according to Priscilla, it sounds nice with the “hub” in ️it🥲</li><li><em>Afmac</em> (App for managing a class💀) — Pricilla’s dad’s genius invention</li><li>and <em>bestuurder</em> which is Afrikaans for manager</li></ul><p>but <em>MySario</em> stuck and the domain was available so we flew with it.</p><h3>Where we are at</h3><p>Since most of us had to travel home for our short break, we’ve had to work remotely. This means we now have more than enough virtual meetings where we spend time saying jokes that Priscilla laughs at 1–5 minute after we’ve said them because GrAndMaSteRs of DaTa or playing Google pronunciation of words we think someone murdered in their speech.</p><p>We’ve been working more than twice as hard as we’ve been having fun though. Our UI implementation of the design is currently 90% complete.</p><p>Sneak peak?🤫</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hdqk9QCtY64zgGRzllsZDw.jpeg" /></figure><h3>The pains we’ve been through</h3><p>From power issues to crashing servers, from changing design requirements as we figure stuff out to finding out that we now have competition. We’ve had a fair share of pains. Add bugs in code and the way logs refuse to show where the goddamn errors are coming from.</p><p>This past week…sighs. See for yourself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U22V-wYtynFMZbpD6AM-Fw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AtKjvyMDbsglzHokFziOXQ.png" /></figure><p>We’ve also had to make tremendous changes to some parts of the app’s design to give y’all quality stuff. These changes translate to more hours of writing code and refactoring already written code. And because we love TDD, we sometimes have to rewrite test cases for these changes🥲.</p><p>In the initial design for MySario, we intended to build something similar to WhatsApp but without the limits. Munachi and Samuel — our designers — came up with this intuitive group chat UI and we planned to accommodate features like important messages (so anyone can find important messages without having to scroll through a litter of GodWhens and Peter-Achimugu-type denials of genius).</p><p>What we noticed was that this introduced complexities that we are better off without. Real-time communication is a hassle. Add caching of messages so you can find your messages even when you’re not connected to the internet. You get MINDFUCK!</p><p>So we had to think of a simpler approach and I believe you’ll love it when you see it. Getting important messages is 200x cleaner, more engaging and a prospect for monetization in future versions.</p><p>Finding out our competition beat us to launch made the reality of things very clear. We now have to move faster and TBH I can’t wait to show you YourSario.</p><p>See you soon!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a5efb232640" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SpaceApp log[0] ]]></title>
            <link>https://medium.com/@devcrazelu/spaceapp-log-0-611839bb77db?source=rss-1e6027398518------2</link>
            <guid isPermaLink="false">https://medium.com/p/611839bb77db</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[students]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Crazelu]]></dc:creator>
            <pubDate>Thu, 22 Jul 2021 21:22:18 GMT</pubDate>
            <atom:updated>2021-07-22T21:22:18.170Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*S0OYU38D_UCloZEE" /><figcaption>Photo by <a href="https://unsplash.com/@ffstop?utm_source=medium&amp;utm_medium=referral">Fotis Fotopoulos</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Hey there, internet wanderer!</p><p>Lucky here with the first SpaceApp log which attempts to capture all the important (and silly) moments my team at SpaceApp share while we’re building this app we think is going to be a big deal.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FPB4Il61ZBkhaymWHOF%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FPB4Il61ZBkhaymWHOF%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FPB4Il61ZBkhaymWHOF%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/e96746efbdcb630474e33b8a3cade787/href">https://medium.com/media/e96746efbdcb630474e33b8a3cade787/href</a></iframe><p>WhatsApp is crawling with a ridiculous number of group chats for University students in Nigeria, and possibly all over the world. Some of these student classes have more people than WhatsApp allows in one group chat and that means class admins have to create multiple groups, duplicate important messages across these groups and manage repeating questions and comments.</p><p>My class doesn’t have this problem though. There’s even a bigger problem!</p><p>Important messages could easily be lost when excited people jump on an interesting topic and everywhere is overflowing with memes, emojis and God-Whens.</p><p>We solved this problem by creating an info group where only class admins post important info and this works for us but for larger classes, there’d be multiple “cruise” groups as well as multiple info groups.</p><p>The pandemic did mess up our calendar and that meant any lecturer could wake up on a fun Monday and reschedule a class. Or another could decide to fix a boring class for painful reasons that’ll never make sense to me. What this meant was our timetable became fluid but there was nobody to keep updating the design. We needed a timetable that reflected changes in real time. Actually, we still do need that because we don’t have it yet.</p><p>Also WhatsApp was made for interpersonal communication. Students need more than that! The first thing I check daily is what classes I have for the day and when, what classes have been rescheduled, if there are assignments that’ll be due soon, if there are tests to prepare for… that kinda stuff.</p><p>What if you had all of these info shown to you in some sweet design without you having to scroll through some text based timetable or having to read all important messages to formulate a schedule for the day? How about reminders some fixed time before these events (lectures, tests, yada yada yada)? Timetable that adjusts to realtime changes in daily events?</p><p>You want all of these, yea? You’s smart. That’s why we’re building SpaceApp for you!</p><p>SpaceApp is a students-first platform that hopes to solve these issues traditional chat platforms like WhatsApp are packed with.</p><p>We are a team of six 3rd year students (we wrote our final exam for 2nd year today 🥳) of Computer Science in the University of Nigeria Nsukka with some insanely rich music taste and great sense of humour — hehe, mostly CEO jokes.</p><p>Currently, we have 80% of the design ready, the backend infrastructures are being put in place and development of the mobile app is underway. We will be live on your phone screens sooooooon!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FJ2aYPy0Fd8oPNITB6u%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fmemecandy-J2aYPy0Fd8oPNITB6u&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2FJ2aYPy0Fd8oPNITB6u%2Fgiphy.gif%3Fcid%3D790b761192fa08eff22295b849bdc3dc54535f00a87e56b4%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="279" frameborder="0" scrolling="no"><a href="https://medium.com/media/5219de1ca63298e370b2b8cca7261779/href">https://medium.com/media/5219de1ca63298e370b2b8cca7261779/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=611839bb77db" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>