<?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[Dev Artel - Medium]]></title>
        <description><![CDATA[We build mobile applications for startups and businesses - Medium]]></description>
        <link>https://medium.com/dev-artel?source=rss----defae019f34c---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Dev Artel - Medium</title>
            <link>https://medium.com/dev-artel?source=rss----defae019f34c---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 20:03:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/dev-artel" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Case study: Sababa]]></title>
            <link>https://medium.com/dev-artel/case-study-sababa-eefd3c8f507e?source=rss----defae019f34c---4</link>
            <guid isPermaLink="false">https://medium.com/p/eefd3c8f507e</guid>
            <dc:creator><![CDATA[Renat Sarymsakov]]></dc:creator>
            <pubDate>Thu, 21 Mar 2024 15:18:12 GMT</pubDate>
            <atom:updated>2024-03-21T15:18:12.064Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l1sEqLBogDTBL0LEkGcPpA.png" /></figure><h3>Intro</h3><p>What does it mean to turn an idea into a product description? Here’s a story on how we did it for a client.</p><h3>The client</h3><p>A coffee-house chain.</p><h3>The idea</h3><p>App to preorder a hot beverage to grab and go.</p><h3>What we did</h3><ol><li>The coffee-chain owner came up with an idea without detailed product requirements</li><li>Firstly, we organized a brainstorming session to gather product ideas from everybody (sticky notes on a board)</li><li>Then, we created a list of possible user interactions in collaboration with the client such as onboarding, the closest coffee spot search, and checkout</li><li>We discovered user scenarios and broke them down into user stories</li><li>Based on user flows, we devised a navigation map for the app. It includes rough description of app screens as well as transitions between them</li><li>In the meantime, the customer picks a project name, registers necessary infrastructure such as Google Play and App Store accounts (with our help, of course!)</li><li>Finally, considering all the product specs, we proceeded with estimating and prepared a solid commercial offer</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s5tVwVc1wVjPQt0UGxn8og.png" /><figcaption>This is an example of navigation map</figcaption></figure><h3>What is a design sprint exactly?</h3><p>Design sprint is a methodology created by Google in 2010 and since then it has been widely adopted within the tech industry at any scale to create continuous innovation and to turn ideas into product specifications in the most effective and valuable way possible.</p><p><a href="https://en.wikipedia.org/wiki/Design_sprint">Here</a> you can find a brief summary of the topic. If you have a bit more time to read, <a href="https://www.smashingmagazine.com/2014/08/getting-started-with-design-sprints/">this article</a> goes into more details. If you’re wondering about the actual value design sprints create, <a href="https://design.google/library/design-sprints">here</a> you can find a “oral history” of the methodology told by Google employees who applied it extensively through the years.</p><h3>How does it work?</h3><p>It’s a 3 days workshop. The first day will be focused on understanding the problems to solve and to seize ideas and opportunities. The second on defining how to solve such problems and on storyboarding, while the third one will be dedicated to prototyping and testing.</p><h3>Who should attend it?</h3><p>On our side (Dev Artel):</p><ul><li>One Moderator</li><li>One Designer</li><li>One or two Senior Developer(s)</li><li>One Product Manager</li></ul><p>On your side (the Client): pretty much anyone who can provide valuable input! Of course it shouldn’t be too many people and there should be enough diversity of knowledge and expertise. But fear not! We will discuss with you all the details beforehand and make sure that the right people are in the room (or in the call) during the sprint.</p><h3>What do you (the client) get out of it?</h3><p>To put it simply, after the design sprint your ideas will have been turned into concrete assets and you will be ready to start developing your product. The assets in questions will be of different kinds, such as wireframes, product specifications, user stories, prototypes and mockups.</p><h3>I’m interested! what’s next?</h3><p>Just <a href="/service/mailto:info@devartel.io">let us know</a>, we will take it from there. We will first organize a call (or, in some cases, more than one will be necessary) to gather all the info we need to start the preparation for the design sprint. We then agree on the dates (in principle, every participant must be available full-time during the 3 days) and send you all the information about what you need to prepare and how exactly the sprint will be structured.</p><p>Do you prefer to develop the product in-house or to move forward with another company? No hard feelings! We keep the payment and the output of the design sprint is, of course, yours. This way you will have everything you need to start building.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eefd3c8f507e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dev-artel/case-study-sababa-eefd3c8f507e">Case study: Sababa</a> was originally published in <a href="https://medium.com/dev-artel">Dev Artel</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chatterbox: A Comprehensive Framework for Building Dialogs with Telegram Chatbots]]></title>
            <link>https://medium.com/dev-artel/chatterbox-a-comprehensive-framework-for-building-dialogs-with-telegram-chatbots-fde2cabd93f0?source=rss----defae019f34c---4</link>
            <guid isPermaLink="false">https://medium.com/p/fde2cabd93f0</guid>
            <category><![CDATA[chatbot-development]]></category>
            <category><![CDATA[telegram-bot]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Danny Vien]]></dc:creator>
            <pubDate>Thu, 18 Jan 2024 13:57:48 GMT</pubDate>
            <atom:updated>2024-01-18T14:22:02.739Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t8y4oMXekqjTMx5IldIWMg.png" /></figure><h3>Intro</h3><p>Chatbots are becoming increasingly popular because users can interact with them within the app they are already using. That’s why building a user-facing product as a chatbot is a good idea for product validation.</p><p>Developing a chatbot requires less time to test your idea since there is no need to create a UI. Instead, you can focus on implementing a dialog flow.</p><p>We created Chatterbox to simplify complex dialog flows and maintain context.</p><h3>Problem</h3><p>The most straightforward method of communicating with the Telegram Bot API is by utilizing their REST API. However, this can be challenging for the average developer and may impede the development process. To accelerate development, API wrappers such as <a href="https://pub.dev/packages/televerse">Televerse</a> or Teledart can be used. These wrappers do not, however, offer high-level abstractions for intricate dialog flows.</p><h3>Solution</h3><p>Check <a href="https://medium.com/@oktaykopcak/testing-your-telegram-bot-with-ngrok-a-step-by-step-guide-81c8c4a9a853">this article</a> on how to set up a Telegram bot and connect it to a local machine with <a href="https://ngrok.com/download">ngrok</a>.</p><p>Let’s start with concept and components of Chatterbox. The base building block of a Chatterbox app is a <strong>Flow</strong>. A <strong>Flow</strong> is a conversation branch that can be triggered by one of the following events:</p><ul><li>Command (starts with ‘/’)</li><li>Arbitrary user input</li><li>Redirect from another <strong>Flow</strong></li></ul><p>A <strong>Flow</strong> consists of <strong>Step</strong>s. For example, in an onboarding <strong>Flow</strong>, a chatbot may gather a user&#39;s email, name, and age. This <strong>Flow</strong> consists of three <strong>Step</strong>s, which can be triggered by user input or by another <strong>Step</strong>, and produce a chatbot <strong>Reaction</strong>.</p><p><strong>Reaction</strong> types:</p><ul><li><strong>None</strong> – no reaction</li><li><strong>Response</strong> – send a message to a user</li><li><strong>Redirect</strong> – invoke another <strong>Step</strong> or <strong>Flow</strong></li><li><strong>Invoice</strong> – issue an invoice for a user</li><li><strong>Composed</strong> – combines several reactions</li></ul><p><strong>Steps</strong> are identified and can be linked by <strong>URIs. URI </strong>is inferred from <strong>Step </strong>name (<em>for that reason every step in your program must use unique name</em>) and might include arguments. <a href="https://core.telegram.org/bots/api#inlinekeyboardbutton">Telegram enforces limit of 64 bytes</a> for such data. To produce a <strong>URI</strong> use extension method toStepUri:</p><pre>(MyStep).toStepUri([&quot;param1&quot;, &quot;param2&quot;])</pre><p>Notice, that all arguments are strings. They can be received in MyStep handle method:</p><pre>Future&lt;Reaction&gt; handle(MessageContext messageContext, [List&lt;String&gt;? args])</pre><h3>Example</h3><h3>Game concept</h3><p>To illustrate key concepts, let’s develop a simple yet fun and enjoyable game. The game rules are very simple:</p><blockquote><em>In the game of 21 Sticks, two players take turns removing 1 to 3 sticks from a total of 21. The player who takes the last stick loses.</em></blockquote><p>The game can be implemented as a single Chatterbox <strong>Flow:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FCdJHUNwupEMJuPOB7a22g.png" /><figcaption>Game Flow Diagram</figcaption></figure><h3>Detailed description</h3><p>Chatterbox is initialized by following params:</p><ul><li>botToken— see <a href="https://core.telegram.org/bots/api#authorizing-your-bot">Telegram documentation</a> to get one</li><li>flows— an array of flows, we’ll create one below</li><li>store — a way to keep conversation context between invocations. For this example we’ll use InMemoryStore(), kindly provided by the library</li></ul><pre>final flows = &lt;Flow&gt;[ CountdownGameFlow()];<br>Chatterbox(botToken: botToken, flows: flows, store: InMemoryStore()).invokeFromWebhook(json);</pre><p><strong>Flow</strong> is simply an array of steps</p><pre>class TwentyOneSticksGameFlow extends Flow {<br>  @override<br>  List&lt;StepFactory&gt; get steps =&gt; [<br>    //todo<br>  ];<br>}</pre><p>Now we’ll be adding those steps one by one:</p><ul><li>The flow begins with <strong>StartStep</strong>, which greets the user and redirects to a <strong>User</strong> step. To greet the user and begin waiting for their turn, we combine two reactions using <strong>ReactionComposed</strong>. <strong>ReactionRedirect</strong> then redirects the execution flow to a provided <strong>Step</strong>.</li></ul><pre>class StartStep extends FlowStep {<br>  @override<br>  Future&lt;Reaction&gt; handle(MessageContext messageContext, [List&lt;String&gt;? args]) async {<br>    return ReactionComposed(responses: [<br>      ReactionResponse(<br>        text:<br>            &quot;In the game of 21 Sticks, two players take turns removing 1 to 3 sticks from a total of 21. The player forced to take the last stick loses.&quot;,<br>      ),<br>      ReactionRedirect(stepUri: (_UserTurnStep).toStepUri())<br>    ]);<br>  }<br>}</pre><ul><li>The next <strong>Step</strong> is to wait for user keyboard input. An inline keyboard displays buttons under the message text. The <strong>InlineButton</strong> receives a <strong>nextStepUri</strong> parameter that defines the <strong>Step</strong> to be invoked on a button click. Also, note the array of parameters that are passed to the next <strong>Step</strong> via a URI.</li></ul><pre>class _UserTurnStep extends FlowStep {<br>  @override<br>  Future&lt;Reaction&gt; handle(MessageContext messageContext, [List&lt;String&gt;? args]) async {<br>    final number = (args?.firstOrNull ?? &#39;21&#39;);<br><br>    return ReactionResponse(<br>        text: &#39;There are $number sticks.\\n\\nHow many sticks do you want to take?&#39;,<br>        buttons: [<br>          InlineButton(title: &#39;One&#39;, nextStepUri: (_GameProcessingStep).toStepUri([_Player.user.name, number, &#39;1&#39;])),<br>          InlineButton(title: &#39;Two&#39;, nextStepUri: (_GameProcessingStep).toStepUri([_Player.user.name, number, &#39;2&#39;])),<br>          InlineButton(title: &#39;Three&#39;, nextStepUri: (_GameProcessingStep).toStepUri([_Player.user.name, number, &#39;3&#39;])),<br>        ].sublist(0, min(3, int.parse(number))));<br>  }<br>}</pre><ul><li>Once a user submits input, the <strong>_GameProcessingStep</strong> is triggered. First, we retrieve the passed parameters and determine if the game has finished or can be continued. It is important to note that we use <strong>ReactionComposed</strong> again, but this time to edit a previous message with buttons that display the user&#39;s choice in the same message, rather than submitting to new messages. We then pass control flow to the next step. If a winner is determined, the <strong>_OnPlayerWonStep</strong> is invoked by passing the winner as a parameter. Otherwise, the game continues.</li></ul><pre>class _GameProcessingStep extends FlowStep {<br>  @override<br>  Future&lt;Reaction&gt; handle(MessageContext messageContext, [List&lt;String&gt;? args]) async {<br>    final actor = _Player.values.byName(args!.first);<br>    final originalNumber = int.parse(args.elementAtOrNull(1)!);<br>    final playerChoice = int.parse(args.elementAtOrNull(2)!);<br><br>    final sticksLeft = originalNumber - playerChoice;<br><br>    final reaction = switch (sticksLeft) {<br>      1 =&gt; ReactionRedirect(stepUri: (_OnPlayerWonStep).toStepUri([actor.name])),<br>      0 =&gt; ReactionRedirect(stepUri: (_OnPlayerWonStep).toStepUri([actor.getOpponent.name])),<br>      _ =&gt; ReactionRedirect(stepUri: (_GameLooperStep).toStepUri([actor.name, &#39;$sticksLeft&#39;])),<br>    };<br><br>    return ReactionComposed(responses: [<br>      if (actor == _Player.user)<br>        ReactionResponse(<br>          text: &#39;There are $originalNumber sticks.\\n\\nYou took out $playerChoice sticks.&#39;,<br>          editMessageId: messageContext.editMessageId,<br>        ),<br>      reaction,<br>    ]);<br>  }<br>}</pre><ul><li>The purpose of <strong>GameLooperStep</strong> is to determine whose turn it is:</li></ul><pre>class _GameLooperStep extends FlowStep {<br>  @override<br>  Future&lt;Reaction&gt; handle(MessageContext messageContext, [List&lt;String&gt;? args]) async {<br>    final actor = _Player.values.byName(args!.first);<br>    final sticksLeft = int.parse(args.elementAtOrNull(1)!);<br><br>    return switch (actor) {<br>      _Player.user =&gt; ReactionRedirect(stepUri: (_BotTurnStep).toStepUri([&#39;$sticksLeft&#39;])),<br>      _Player.bot =&gt; ReactionRedirect(stepUri: (_UserTurnStep).toStepUri([&#39;$sticksLeft&#39;])),<br>    };<br>  }<br>}</pre><ul><li><strong>BotTurnStep</strong> implements the logic for the bot to draw a random number of sticks. To prevent the bot from drawing more sticks than are available, the <strong>min()</strong> function is used.</li></ul><pre>class _BotTurnStep extends FlowStep {<br>  @override<br>  Future&lt;Reaction&gt; handle(MessageContext messageContext, [List&lt;String&gt;? args]) async {<br>    final sticksLeft = int.parse(args!.first);<br><br>    final botTurn = Random().nextInt(min(3, sticksLeft)) + 1;<br><br>    await Future.delayed(Duration(milliseconds: 300));<br><br>    return ReactionComposed(responses: [<br>      ReactionResponse(<br>        text: &#39;There are $sticksLeft sticks.\\n\\nBot takes out $botTurn sticks.&#39;,<br>      ),<br>      ReactionRedirect(<br>        stepUri: (_GameProcessingStep).toStepUri([&#39;bot&#39;, sticksLeft.toString(), botTurn.toString()]),<br>      ),<br>    ]);<br>  }<br>}</pre><ul><li>Finally, the last <strong>Step</strong> is to congratulate the winner or mock the loser.</li></ul><pre>class _OnPlayerWonStep extends FlowStep {<br>  @override<br>  Future&lt;Reaction&gt; handle(MessageContext messageContext, [List&lt;String&gt;? args]) async {<br>    final actor = _Player.values.byName(args!.first);<br><br>    final text = switch (actor) {<br>      _Player.user =&gt; &#39;Congratulations, you won! 🎉✨&#39;,<br>      _Player.bot =&gt; &#39;Oh, no, you are a looser! 💩😱&#39;,<br>    };<br><br>    return ReactionComposed(responses: [<br>      ReactionResponse(<br>        text: text,<br>      ),<br>    ]);<br>  }<br>}</pre><h3>Outro</h3><p>Investigate the libraries <a href="https://github.com/DevArtel/chatterbox">code</a> or run the example yourself.</p><p>Or jump directly to Telegram to play amazing game of sticks with <a href="https://t.me/AmazingGameOfSticksBot">AmazingGameOfSticksBot</a>!</p><p>Thanks for your attention. <a href="/service/mailto:info@devartel.io">Let us know</a> if you need the library in some other language.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fde2cabd93f0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dev-artel/chatterbox-a-comprehensive-framework-for-building-dialogs-with-telegram-chatbots-fde2cabd93f0">Chatterbox: A Comprehensive Framework for Building Dialogs with Telegram Chatbots</a> was originally published in <a href="https://medium.com/dev-artel">Dev Artel</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Choosing between in-house and outsourced development]]></title>
            <link>https://medium.com/dev-artel/choosing-between-in-house-and-outsourced-development-11090ae68285?source=rss----defae019f34c---4</link>
            <guid isPermaLink="false">https://medium.com/p/11090ae68285</guid>
            <category><![CDATA[outsourcing]]></category>
            <category><![CDATA[inhouse-development]]></category>
            <category><![CDATA[inhouse-vs-outsourcing]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Renat Sarymsakov]]></dc:creator>
            <pubDate>Thu, 02 Nov 2023 14:44:46 GMT</pubDate>
            <atom:updated>2024-02-08T15:12:59.023Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QPf0IvGAxoRRKWLfiWGRIA.png" /></figure><h3>📒 Intro</h3><p>Just imagine: you have a one-million-worth idea. But who precisely shall execute your vision and turn it into a thriving business venture?</p><p>There are two ways to build development teams:</p><ul><li>You can establish a company and hire a key role such as a CTO to recruit an in-house team of tech specialists.</li><li>Alternatively, you can choose to outsource.</li></ul><p>But what should you pick for your case?</p><h3>🙇 Challenges along the way</h3><p>Undoubtedly, any business owner wants a quick start and fast delivery of their idea for the cheapest price.</p><p>It is expected that a business owner will face certain risks during the development process, such as:</p><ul><li>Costly development;</li><li>Hidden costs (HR services; paid sick leave; employment tax)</li><li>Delays in team formation (due to the founder’s lack of knowledge of development organization; lengthy time frame for hiring a developer)</li><li>Difficulties in adjusting the dev process to meet business requirements;</li><li>Motivation decrease;</li><li>Departure of key people.</li></ul><h3>⚖️ Weighing risks</h3><p>To choose a process, you need to determine your capabilities. The table below shows the main costs for each process:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nGeT-lYPpJdU2HqvyN8tRQ.png" /><figcaption>(*) depends on expertise and location in Europe</figcaption></figure><p>Based on our own experience, each development approach carries the following risks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VkeQnnxpE3n2htS_bUdTsw.png" /></figure><h3>✅ Conclusion</h3><p>So which way is suitable for you?</p><p>If your business is well-established with a functional HR department and a clear project plan, you may prefer to opt for in-house development. This will offer greater flexibility if you need to adjust project scope (including pivoting), team structure (e.g. creating smaller teams from development guilds), or terms of work (such as introducing share appreciation rights).</p><p>If none of the above applies, outsourcing may be a suitable option. This will provide comprehensive risk coverage for a reasonable price.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11090ae68285" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dev-artel/choosing-between-in-house-and-outsourced-development-11090ae68285">Choosing between in-house and outsourced development</a> was originally published in <a href="https://medium.com/dev-artel">Dev Artel</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shaders in Flutter]]></title>
            <link>https://medium.com/dev-artel/shaders-in-flutter-1562fd33b994?source=rss----defae019f34c---4</link>
            <guid isPermaLink="false">https://medium.com/p/1562fd33b994</guid>
            <category><![CDATA[shaders]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Vasily Styagov]]></dc:creator>
            <pubDate>Fri, 20 Oct 2023 14:06:30 GMT</pubDate>
            <atom:updated>2023-10-20T14:06:29.957Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N-UNfBgU1hCG8R_h4x7nrw.png" /></figure><h3>What is a shader?</h3><p>A shader is a computer program embedded into a rendering pipeline. It is a brief program that runs on the GPU and can be effectively parallelized. When executed, the shader can define the color of each pixel in a rendered image or transform the coordinates of a vertex.</p><h3>Why consider using them?</h3><p>Ever wondered how to incorporate eye-catching visual effects in your app or game? Like:</p><ul><li>Particle systems (for instance, smoke);</li><li>Ocean waves;</li><li>Ambient occlusion;</li><li>Global illumination.</li></ul><p>Utilize the full potential of your GPU by employing shaders for these purposes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*cZv-8dQT-4FQCKYkBKxzKg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*mSMChXFev9uhcUMZEQGQbw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*i2PAE76UKwjI_njsIBtuhA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*90gm3c4NTSxtLc62O5YkOA.jpeg" /><figcaption>Clockwise, starting from top left: particle systems, per-pixel lighting, global illumination, ambient occlusion.</figcaption></figure><h3>Types of shaders</h3><p>Let’s begin with basic definitions. A <strong>primitive</strong> refers to a group of vertices and the methods of linking them.</p><p>Shaders can be:</p><ul><li><strong>Fragment/pixel shaders</strong> are programs that execute during the rasterization stage. They operate on each pixel to determine its final color and can be used for tasks such as applying textures or calculating lighting. There are two fundamental concepts:<br>‣ <strong>Fragment.</strong> A renderer creates fragments, which are the smallest unit of data produced by rasterization. A fragment does not always correspond to a physical pixel. In cases of multi-sampling, several fragments combine to produce the color of a single pixel. The area of a fragment is related to the area of a pixel.<br>‣ <strong>Pixel</strong> is a singular point on the physical screen.</li><li><strong>Vertex shader</strong> takes only a single primitive as an argument and returns only a single primitive as a result.</li><li><strong>Geometry shaders</strong> take one primitive as input and can output zero or more primitives.</li><li><strong>Compute shaders</strong> are a type of shader that does not deal with graphics and instead utilizes GPU computational power for tasks such as physics computations.</li></ul><p>Let’s explain our rendering process in simple words. Imagine a scene made up of basic primitives.</p><ol><li>The user’s program defines primitives, colors, textures, camera position, and orientation through method calls of graphics APIs such as <a href="https://en.wikipedia.org/wiki/Direct3D">Direct3D</a> and <a href="https://en.wikipedia.org/wiki/Vulkan">Vulkan</a>.</li><li>Vertex shaders are supplied with primitive vertex data to undergo additional transformations, such as animations.</li><li>The geometry shader receives primitives with transformed vertices and has the option to either generate new primitives or output zero.</li><li>After applying viewport and perspective transformations as well as textures, the geometry generated by the geometry shader is rasterized to obtain the colors of pixels.</li><li>Fragment shaders alter the colors of pixels to simulate lighting and other per-pixel effects.</li></ol><h3>Simple example</h3><p>In its simplest form, a shader consists of the following parts:</p><ol><li><strong>Includes.</strong> The part describes dependencies of the shader. In this example, we include flutter/runtime_effect.glsl containing a convenient function to obtain coordinates of a fragment being processed.</li><li><strong>Uniforms.</strong> These are the parameters sent from a client to a shader program. They are called uniforms because their values remain constant across multiple calls to the program.</li><li><strong>Output fragment values.</strong> It’s the result of program execution. It can be a color or a depth value.</li><li><strong>The code of the program itself.</strong> The entry function (called main) contains code in a C-like language called GLSL.</li></ol><p>Here’s a simple example of a fragment shader:</p><pre>// 1<br>#include &lt;flutter/runtime_effect.glsl&gt;<br><br>// 2<br>uniform vec2 uSize;<br>uniform vec4 uColor;<br><br>// 3<br>out vec4 fragColor;<br><br>// 4<br>void main() {<br>    vec2 currentPos = FlutterFragCoord().xy / uSize;<br>    float multiplier = currentPos.x * currentPos.y;<br>    fragColor = vec4(uColor.r * multiplier, uColor.g * multiplier, uColor.b * multiplier, uColor.a);<br>}</pre><p>Let’s review it section by section:</p><ol><li>Section 1 includes handy helpers as we mentioned above.</li><li>Section 2 describes input data represented as vectors. The size vector contains 2 values denoting the X and Y coordinates, while the color vector consists of 4 values representing the red, green, blue, and alpha components.</li><li>In section 3, fragColor is a reserved word. The shader uses it to write a calculated color of the current fragment.</li><li>In the main function (section 4), we calculate the position within the range of [0..1]. Then we multiply it by each component of the color provided in the uniform. We create a new vec4 out of these values and set it as the output value.</li></ol><p>As a result we get a nice gradient from black to uColor. And this program is evaluated for every fragment of the rendered image.</p><h3>How to load a shader in Flutter code</h3><p>So, we devised a shader program. The following step is to use it within the application.</p><p>To access the program, it must be included in the project. The shader program file should be placed in the shaders directory located at the root of your project. To include the file in the project binary, reference it in the flutter/shaders section of the Pubspec.yaml file:</p><pre>flutter:<br>  shaders:<br>    - shaders/shader.frag</pre><p>Next we load the fragment program from assets:</p><pre>class ShaderWidget extends StatefulWidget {<br>  const ShaderWidget({Key? key}) : super(key: key);<br><br>  @override<br>  State&lt;ShaderWidget&gt; createState() =&gt; _ShaderWidgetState();<br>}<br><br>class _ShaderWidgetState extends State&lt;ShaderWidget&gt; {<br>  FragmentShader? shader;<br><br>  @override<br>  void initState() {<br>    super.initState();<br><br>    _loadMyShader();<br>  }<br><br>  Future&lt;void&gt; _loadMyShader() async {<br>    var program = await FragmentProgram.fromAsset(&#39;shaders/shader.frag&#39;);<br>    setState(() {<br>      shader = program.fragmentShader();<br>    });<br>  }<br><br>  // ... <br>}</pre><p>That’s it! Once the shader is loaded, we can paint it on Canvas:</p><pre>class MyPainter extends CustomPainter {<br>  MyPainter({<br>    required this.shader,<br>  });<br><br>  final FragmentShader shader;<br><br>  @override<br>  void paint(Canvas canvas, Size size) {<br>    final random = Random();<br><br>    shader<br>      ..setFloat(0, size.width) // width<br>      ..setFloat(1, size.height) // height<br>      ..setFloat(2, random.nextDouble()) // red<br>      ..setFloat(3, random.nextDouble()) // green<br>      ..setFloat(4, random.nextDouble()) // blue<br>      ..setFloat(5, 1); // alpha<br><br>    final paint = Paint()..shader = shader;<br>    canvas.drawRect(Rect.fromLTWH(0, 0, size.width, size.height), paint);<br>  }<br><br>  @override<br>  bool shouldRepaint(covariant CustomPainter oldDelegate) =&gt; true;<br>}</pre><p>In the paint method, we pass uniform values to the shader. For instance, at the first position in the shader program, we have uniform vec2 uSize, which is a vector of two values. This implies that we should pass values to parameters with indices 0 and 1. These values are stored between frames and can be updated anytime.</p><p>Lastly, use this Painter.</p><pre>class _ShaderWidgetState extends State&lt;ShaderWidget&gt; {<br>  FragmentShader? shader;<br><br>  // ...<br><br>  @override<br>  Widget build(BuildContext context) {<br>    final shader = this.shader;<br>    return shader == null // As the shader is loaded ascynchronously, we need to render something meanwhile<br>        ? const Center(<br>            child: CircularProgressIndicator(),<br>          )<br>        : CustomPaint(<br>            painter: MyPainter(shader: shader),<br>          );<br>  }<br>}</pre><p>Et voilá! We’ve just successfully painted a gradient with a fragment shader!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ERz9krFwiOGisAE23bQ9w.png" /></figure><h3>Flutter limitations</h3><p>When working with shaders in Flutter, it’s important to be aware of certain limitations and constraints that can impact your shader development.</p><ul><li>Only fragment shaders are supported.</li><li>Supported GLSL versions are 100–460.</li><li>Buffer Objects are not supported. Buffer Objects are essential for efficient data storage and transfer in OpenGL, and their absence in Flutter can impact certain advanced rendering techniques. Be prepared to work within this constraint when designing your shader-based applications.</li><li>Only 2D samples (textures) are supported. If your application relies on 3D textures or other types, you may need to find alternative solutions or work within the confines of 2D textures.</li><li>Unsigned types are not supported as well.</li></ul><p>Understanding these limitations is crucial for effectively using shaders in Flutter. By being mindful of these constraints and working within them, you can harness the power of shaders to enhance the visual quality and interactivity of your Flutter applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1562fd33b994" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dev-artel/shaders-in-flutter-1562fd33b994">Shaders in Flutter</a> was originally published in <a href="https://medium.com/dev-artel">Dev Artel</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Localization in multi-module project with intl_utils]]></title>
            <link>https://medium.com/dev-artel/localization-in-multi-module-project-with-intl-utils-cc82b3a41113?source=rss----defae019f34c---4</link>
            <guid isPermaLink="false">https://medium.com/p/cc82b3a41113</guid>
            <category><![CDATA[localization]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Renat Sarymsakov]]></dc:creator>
            <pubDate>Thu, 03 Aug 2023 14:00:29 GMT</pubDate>
            <atom:updated>2023-08-03T14:07:41.375Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mDQcfZMprkoZG7fiQRiiCw.png" /></figure><h3>Disclaimer</h3><p>You will find this article useful if you rely on <a href="https://pub.dev/packages/intl_utils"><strong>intl_utils</strong></a>. For new projects, we recommend using a <a href="https://docs.flutter.dev/accessibility-and-localization/internationalization">modern localization solution</a> provided by Flutter framework.</p><h3>Intro</h3><p>Any mobile application that aims at the global market requires localization. Localization is carried out by keeping strings separate from code via resource files (e.g., ARB files). As the complexity of the application increases, you have to divide the codebase into several modules. Each module contains a set of classes and resources, which are tailored to perform a single function. This is where you may encounter a problem in the modularization of string resources.</p><p>What are the benefits of such architecture?</p><ul><li>You can extract your UI components into a separate library and use it in your app as well as in the app’s storybook</li><li>You can move features into feature modules to manage visibility of feature classes</li><li>You are sure that all your dependencies are isolated from non-compatible environments</li></ul><p>When localizing an app in Flutter, you utilize localization delegates. These are generated from string resource files during the construction of a MaterialApp, as follows:</p><pre>final localizationDelegates = &lt;LocalizationsDelegate&lt;Object&gt;&gt;[<br>  // app-specific localization delegate(s) here<br>];<br><br>// ...<br><br>const MaterialApp(<br>  localizationsDelegates: &lt;LocalizationsDelegate&lt;Object&gt;&gt;[<br>    ...localizationDelegates,<br>    GlobalMaterialLocalizations.delegate,<br>    GlobalWidgetsLocalizations.delegate,<br>  ],<br>  supportedLocales: &lt;Locale&gt;[<br>    Locale(&#39;en&#39;, &#39;US&#39;), // English<br>    Locale(&#39;he&#39;, &#39;IL&#39;), // Hebrew<br>    // ... other locales the app supports<br>  ],<br>  // ...<br>)</pre><p>However, if you try to add multiple delegates with the same locale (in a multilingual application), derived from different packages, only the first batch of strings will be added. It works fine with the initial language of the app. But we face a problem once we change a language either in the app or in the system preferences.</p><p>Suppose we have a main app module and a module containing widgets:</p><pre>// ui.dart<br><br>class Greeting extends StatelessWidget {<br>  const Greeting({super.key});<br>  @override<br>  Widget build(BuildContext context) =&gt; Text(<br>        S.of(context).helloA,<br>      );<br>}</pre><pre>// main.dart<br><br>class Demo extends StatelessWidget {<br>  const Demo({super.key});<br>  @override<br>  Widget build(BuildContext context) =&gt; Scaffold(<br>        appBar: AppBar(<br>          title: Text(S.of(context).title),<br>        ),<br>        body: Center(<br>          child: Column(<br>            mainAxisAlignment: MainAxisAlignment.center,<br>            children: [<br>              const ui.Greeting(),<br>              TextButton(<br>                onPressed: () =&gt; LocaleNotifier.instance.switchLocale(),<br>                child: Text(S.of(context).changeLanguage),<br>              ),<br>            ],<br>          ),<br>        ),<br>      );<br>}</pre><p>Note that each of files uses their own S.of(context). This works as expected when you launch the app. But if you change language, you notice that only a title in the AppBar changes.</p><h3>Let’s take a deep dive</h3><p>The cause can be traced back to the internals of the <a href="https://pub.dev/packages/intl_utils"><strong>intl_utils</strong></a> package.</p><p>Within this package, the method <a href="https://api.flutter.dev/flutter/message_lookup_by_library/CompositeMessageLookup/addLocale.html"><strong>addLocale</strong></a> in the message lookup class ignores the ones that have been added previously:</p><pre>@override<br>void addLocale(String localeName, Function findLocale) {<br>  if (!localeExists(localeName)) {<br>    // ...<br>  }<br>  // ...<br>}</pre><p>However, this issue does not affect the stacking of **GlobalMaterialLocalizations** and **GlobalWidgetsLocalizations** messages.</p><h3>Why do Global*Localization delegates work?</h3><p>As of today, the mechanism for localizing Material widgets is kept completely separate from user-defined localizations. <strong>Global*Localization</strong> delegates are accessible via context. For example, let&#39;s take a look at the <strong>build</strong> method of <strong>AboutListTile</strong>:</p><pre>@override<br>Widget build(BuildContext context) {<br>  assert(debugCheckHasMaterial(context));<br>  assert(debugCheckHasMaterialLocalizations(context));<br>  return ListTile(<br>    leading: icon,<br>    title: child ?? Text(MaterialLocalizations.of(context).aboutListTileTitle(<br>      applicationName ?? _defaultApplicationName(context),<br>    )),<br>    dense: dense,<br>    onTap: () {<br>      showAboutDialog(<br>        context: context,<br>        applicationName: applicationName,<br>        applicationVersion: applicationVersion,<br>        applicationIcon: applicationIcon,<br>        applicationLegalese: applicationLegalese,<br>        children: aboutBoxChildren,<br>      );<br>    },<br>  );<br>}</pre><p>As you can see, <strong>aboutListTileTitle</strong> is obtained by first retrieving <strong>MaterialLocalizations</strong> from the current build context.</p><h3>Fixing the problem</h3><p>Suppose you use <a href="https://pub.dev/packages/intl_utils"><strong>intl_utils</strong></a> to manage ARB files in your Flutter application. The first step to solving the problem is to create a custom localization delegate class. This class should use <strong>MultipleLocalizations.load</strong> from the <a href="https://pub.dev/packages/multiple_localization"><strong>multiple_localization</strong></a> plugin to bypass the <strong>addLocale</strong> check:</p><pre>class _LocalizationsDelegate&lt;T&gt; extends LocalizationsDelegate&lt;T&gt; {<br>  _LocalizationsDelegate({<br>    required this.isLocaleSupported,<br>    required this.initializeMessages,<br>    required this.builder,<br>  });<br>	<br>  bool Function(Locale locale) isLocaleSupported;<br>  Future&lt;bool&gt; Function(String) initializeMessages;<br>  FutureOr&lt;T&gt; Function(String locale) builder;<br>	<br>  @override<br>  bool isSupported(Locale locale) =&gt; isLocaleSupported(locale);<br>	<br>  @override<br>  Future&lt;T&gt; load(Locale locale) {<br>    return MultipleLocalizations.load(<br>      initializeMessages,<br>      locale,<br>      builder,<br>      setDefaultLocale: true,<br>    );<br>  }<br>	<br>  @override<br>  bool shouldReload(LocalizationsDelegate&lt;T&gt; old) =&gt; false;<br>}</pre><p>Then, you should construct your localization delegates in the following manner:</p><pre>LocalizationsDelegate&lt;app.S&gt; _appLocalizationsDelegate = _LocalizationsDelegate(<br>  isLocaleSupported: app.S.delegate.isSupported,<br>  initializeMessages: app.initializeMessages,<br>  builder: (locale) async {<br>    await app.S.load(Locale(locale));<br>    return app.S();<br>  },<br>);<br>	<br>LocalizationsDelegate&lt;ui.S&gt; _uiLocalizationsDelegate = _LocalizationsDelegate(<br>  isLocaleSupported: ui.S.delegate.isSupported,<br>  initializeMessages: ui.initializeMessages,<br>  builder: (locale) async {<br>    await ui.S.load(Locale(locale));<br>    return ui.S();<br>   },<br>);</pre><p>Lastly, simply use your delegates when calling the app’s constructor:</p><pre>// main.dart<br><br>@override<br>build(BuildContext context){<br>  return MaterialApp.router(<br>    //...<br>    localizationsDelegates: [<br>      _appLocalizationsDelegate,<br>      _uiLocalizationsDelegate,<br>      GlobalMaterialLocalizations.delegate,<br>      GlobalWidgetsLocalizations.delegate,<br>      GlobalCupertinoLocalizations.delegate,<br>    ],<br>    supportedLocales: S.delegate.supportedLocales,<br>  );<br>}</pre><p>Please note that in the following example, all delegates should support the same set of locales. You can find the code for this example on our GitHub page.</p><p><a href="https://github.com/DevArtel/intl_utils_demo">GitHub - DevArtel/intl_utils_demo</a></p><h3>Final thoughts</h3><p>With sufficient effort, a lot is possible. Nevertheless, it would be great if a fix could be deployed for everyone as part of the <strong>intl_utils</strong> library.</p><p>We would also like to extend our gratitude to the team at <a href="https://medium.com/u/8bd0ac8f9344"><strong>Innim IT company</strong></a><strong> </strong>for providing <strong>multiple_localization</strong>. Keep up the good work, guys!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc82b3a41113" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dev-artel/localization-in-multi-module-project-with-intl-utils-cc82b3a41113">Localization in multi-module project with intl_utils</a> was originally published in <a href="https://medium.com/dev-artel">Dev Artel</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>