<?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 Pradyuman Tomar on Medium]]></title>
        <description><![CDATA[Stories by Pradyuman Tomar on Medium]]></description>
        <link>https://medium.com/@iampradyuman18?source=rss-8eadd40cb00e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*oZCMjuY9nPYzoyhrcdXlDA.jpeg</url>
            <title>Stories by Pradyuman Tomar on Medium</title>
            <link>https://medium.com/@iampradyuman18?source=rss-8eadd40cb00e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 21:21:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@iampradyuman18/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[What is runZonedGuarded Function in Flutter ?]]></title>
            <link>https://iampradyuman18.medium.com/what-is-runzonedguarded-function-in-flutter-606541c716c0?source=rss-8eadd40cb00e------2</link>
            <guid isPermaLink="false">https://medium.com/p/606541c716c0</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[apps]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[production]]></category>
            <dc:creator><![CDATA[Pradyuman Tomar]]></dc:creator>
            <pubDate>Wed, 25 Oct 2023 05:57:01 GMT</pubDate>
            <atom:updated>2023-10-25T05:57:01.827Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<h3>What is runZonedGuarded Function in Flutter ?</h3><figure><img alt="Flutter – Medium" src="https://cdn-images-1.medium.com/proxy/1*5-aoK8IBmXve5whBQM90GA.png" /><figcaption>Flutter Image</figcaption></figure><p>In Flutter, the runZonedGuarded function is a way to run a block of code (a callback) within a special zone while also providing a custom error handler to handle any uncaught exceptions that may occur during the execution of that code. This is often used for managing and handling errors in asynchronous code, such as when working with Futures or Streams.</p><p>Here’s a breakdown of its purpose:</p><ol><li>Zones: In Dart, zones are a way to isolate and capture asynchronous errors that occur within a particular scope of code. They allow you to handle errors or exceptions gracefully, preventing them from crashing the entire application.</li></ol><p>2. runZonedGuarded: This function takes two main arguments:</p><ul><li>A callback function: This is the code that you want to run within a specific zone. Any errors thrown within this callback will be captured and handled by the error handler.</li><li>An error handler function: This function is responsible for handling any uncaught exceptions that occur within the callback. It receives two arguments: the error itself and a stack trace.</li></ul><p>Here’s a basic example of how runZonedGuarded might be used in Flutter:</p><pre>runZonedGuarded(() {<br>  // Your code that may throw exceptions<br>  final result = 1 ~/ 0; // This will throw a &#39;Division by zero&#39; exception<br>}, (error, stackTrace) {<br>  // Custom error handling logic<br>  print(&#39;Error: $error&#39;);<br>  print(&#39;Stack Trace: $stackTrace&#39;);<br>});<br><br>/* The rest of your Flutter application continues running even <br> if an error occurs within the callback. */</pre><p>In this example, if an exception is thrown within the callback (in this case, a division by zero error), it will be caught and handled by the error handler. This prevents the exception from crashing the entire Flutter application and allows you to log, report, or handle the error in a more controlled manner.</p><p>runZonedGuarded is particularly useful in scenarios where you want to ensure that your application can gracefully handle errors and continue running even if unexpected exceptions occur in specific parts of your code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=606541c716c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is clean architecture?]]></title>
            <link>https://iampradyuman18.medium.com/what-is-clean-architecture-11cad7a7e012?source=rss-8eadd40cb00e------2</link>
            <guid isPermaLink="false">https://medium.com/p/11cad7a7e012</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Pradyuman Tomar]]></dc:creator>
            <pubDate>Fri, 20 Aug 2021 16:59:56 GMT</pubDate>
            <atom:updated>2021-08-20T16:59:56.890Z</atom:updated>
            <content:encoded><![CDATA[<p>Architecture means the overall design of the project. It’s the organization of the code into classes or files or components or modules. And it’s how all these groups of code relate to each other. The architecture defines where the application performs its core functionality and how that functionality interacts with things like the database and the user interface.</p><p><strong><em>Clean</em></strong> architecture refers to organizing the project so that it’s easy to understand and easy to change as the project grows. This doesn’t happen by chance. It takes intentional planning.</p><h3>Characteristics of a clean architecture</h3><p>The secret to building a large project that is easy to maintain is this: separating the files or classes into components that can change independently of other components. Let’s illustrate that with a couple of images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*bdzN-IZEDBTTee5r.jpeg" /></figure><p>In the image above, if you want to replace the scissors with a knife, what do you have to do? You have to untie the strings that go to the pen, the ink bottle, the tape and the compass. Then you have to retie those items to a knife. Maybe that works for the knife, but what if the pen and the tape say, “Wait, we needed scissors.” So now the pen and the tape don’t work and have to be changed, which in turn affects the objects tied to them. It’s a mess.</p><p>Compare that to this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Xxohp8ountYJK7WW.jpeg" /></figure><p>Now how do we replace the scissors? We only have to pull the scissors’ string out from under the Post-it notes and add a new string that is tied to a knife. Way easier. The Post-it notes don’t care because the string wasn’t even tied to it.</p><p>The architecture represented by the second image was obviously easier to change. As long as the Post-it notes don’t need to be changed often, this system will be very easy to maintain. This same concept is the architecture that will make your software easy to maintain and change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*oY-ATujzdYzWc4bn.png" /></figure><p>The inner circle is the domain layer of your application. This is where you put the business rules. By “business” we don’t necessarily mean a company. It just means the essence of what your application does, the core functionality of the code. A translation app translates. An online store has products to sell. These business rules tend to be fairly stable since you are not likely to change the essence of what your app does very often.</p><p>The outer circle is the infrastructure. It includes things like the UI, the database, web APIs, and frameworks. These things are more likely to change than the domain. For example, you are more likely to change how a UI button looks than you are to change how a loan is calculated.</p><p>A boundary between the domain and the infrastructure is set up so that the domain doesn’t know anything about the infrastructure. That means the UI and the database depend on the business rules, but the business rules don’t depend on the UI or database. This makes it a plugin architecture. It doesn’t matter if the UI is a web interface, a desktop app, or a mobile app. It doesn’t matter if the data is stored using SQL or NoSQL or in the cloud. The domain doesn’t care. This makes it easy to change the infrastructure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11cad7a7e012" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding BuildContext in Flutter]]></title>
            <link>https://iampradyuman18.medium.com/understanding-buildcontext-in-flutter-194e4f619319?source=rss-8eadd40cb00e------2</link>
            <guid isPermaLink="false">https://medium.com/p/194e4f619319</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[build-context]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Pradyuman Tomar]]></dc:creator>
            <pubDate>Wed, 02 Jun 2021 09:00:10 GMT</pubDate>
            <atom:updated>2021-06-02T09:00:10.574Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JemWRdvHkhttUd3P-Z94Nw.png" /></figure><p>BuildContext is one of the Flutter core concepts that every Flutter developer should know. Many developers get confused about this term and I saw many questions related to BuildContext on Stackoverflow.</p><p>So, welcome to MindOrks, in this blog, we will understand the concept of BuildContext in Flutter.</p><p>As we all know that in Flutter, everything is a widget. A text, an image, a column, a row, etc everything that you see on the Flutter application is a widget and a parent widget can have one or more child widgets also. The whole widgets of a Flutter application are displayed in the form of a Widget Tree where we connect the parent and child widgets to show a relationship between them. The following is an example of a Widget Tree in Flutter:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/108/0*njXfpATw2EpjacpZ.jpg" /></figure><p>In the above image, you can see that every widget is having someplace in the widget tree i.e. the Scaffold widget is in the MaterialApp widget, the FlatButton widget is under Row widget and so on.</p><p>So, here comes the role of BuildContext. The BuildContext is used to locate a particular widget in a widget tree and every widget has its own BuidContext i.e. a particular BuildContext is associated with only one widget.</p><p>As we know that every widget in Flutter is created by the build method and the build method takes a BuildContext as an argument. This helps the build method to find which widget it is going to draw and also it helps in locating the position of the widget to be drawn in the widget tree. The following is an example of a build method that is returning a MaterialApp:</p><pre><strong>class</strong> <strong>App</strong> <strong>extends</strong> <strong>StatelessWidget</strong> {<br> <strong>@override</strong><br> Widget <strong>build</strong>(BuildContext context) {<br> <strong>return</strong> MaterialApp(<br>      <em>// some more code</em><br>    );<br>  }<br>}</pre><p>If some widget is having some children widgets then both the parent and the children will have their own BuildContext. Now, the BuildContext of the parent widget will be the parent of the BuildContext of its direct children widget. So, for the above Flutter widget tree:</p><ul><li>MaterialApp is having its own BuildContext and it is the parent of Scaffold.</li><li>Scaffold is having its own BuildContext and it is the parent of Center.</li><li>Center is having its own BuildContext and it is the parent of Row.</li><li>Row is having its own BuildContext and it is the parent of FlatButton.</li><li>FlatButton is having its own BuildContext.</li></ul><p>Also, one thing to note here is that widgets are only visible to their BuildContext or to its parent’s BuildContext. So, from a child widget, you can locate the parent widget. For example, if the tree structure is: Scaffold &gt; Center &gt; Row &gt; FlatButton, then you can get the first Scaffold from FlatButton by going up:</p><pre>context.ancestorWidgetOfExactType(Scaffold)</pre><p>You can also locate a child widget from a parent widget and for that, we use InheritedWidgets(We will discuss this in some other blog). This use-case of BuildContext can be used to pass some message form the parent to the child widget in the widget tree.</p><p>Always be careful while using BuildContext i.e. always verify that the context that you are using in the method is the same context that is needed or not. For example, Theme.of(context) looks for the nearest Theme. So, if some widget A is having a Theme in its returned widget tree and it is calling Theme.of(passing its own context) then the build method of widget A will find whatever Theme was an ancestor to the widget A and it will not find the Theme present in the widget A. So, to get the BuildContext of the subpart of the tree, you can use the Builder widget and the context passed to the Builder widget will be the context of that Builder widget only.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=194e4f619319" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why asynchronous code matters in Flutter?]]></title>
            <link>https://iampradyuman18.medium.com/why-asynchronous-code-matters-in-flutter-66c37ba9e43d?source=rss-8eadd40cb00e------2</link>
            <guid isPermaLink="false">https://medium.com/p/66c37ba9e43d</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Pradyuman Tomar]]></dc:creator>
            <pubDate>Tue, 01 Jun 2021 17:30:01 GMT</pubDate>
            <atom:updated>2021-06-01T17:30:01.846Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*lQCBmQpKYMMs_k_Nvr_NIQ.png" /></figure><p>Asynchronous operations let your program complete work while waiting for another operation to finish. Here are some common asynchronous operations:</p><ul><li>Fetching data over a network.</li><li>Writing to a database.</li><li>Reading data from a file.</li></ul><p>To perform asynchronous operations in Dart, you can use the Future class and the async and await keywords.</p><h3>What is a future?</h3><p>A future (lower case “f”) is an instance of the <a href="https://api.dart.dev/stable/dart-async/Future-class.html">Future</a> (capitalized “F”) class. A future represents the result of an asynchronous operation, and can have two states: uncompleted or completed.</p><p><strong>Note:</strong> <em>Uncompleted</em> is a Dart term referring to the state of a future before it has produced a value.</p><h3>Uncompleted</h3><p>When you call an asynchronous function, it returns an uncompleted future. That future is waiting for the function’s asynchronous operation to finish or to throw an error.</p><h3>Completed</h3><p>If the asynchronous operation succeeds, the future completes with a value. Otherwise it completes with an error.</p><h4>Completing with a value</h4><p>A future of type Future&lt;T&gt; completes with a value of type T. For example, a future with type Future&lt;String&gt; produces a string value. If a future doesn’t produce a usable value, then the future’s type is Future&lt;void&gt;.</p><h4>Completing with an error</h4><p>If the asynchronous operation performed by the function fails for any reason, the future completes with an error.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66c37ba9e43d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dart Sound typing and Sound null safety!!!]]></title>
            <link>https://iampradyuman18.medium.com/dart-sound-typing-and-sound-null-safety-5f00f3625ce3?source=rss-8eadd40cb00e------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f00f3625ce3</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Pradyuman Tomar]]></dc:creator>
            <pubDate>Tue, 01 Jun 2021 10:16:07 GMT</pubDate>
            <atom:updated>2021-06-01T10:16:07.892Z</atom:updated>
            <content:encoded><![CDATA[<p>The Dart language is type safe; it uses static type checking to ensure that a variable’s value <em>always</em> matches the variable’s static type. Sometimes, this is referred to as sound typing. Although types are mandatory, type annotations are optional because of type inference. The Dart typing system is also flexible, allowing the use of a dynamic type combined with runtime checks, which can be useful during experimentation or for code that needs to be especially dynamic.</p><p>Dart offers <a href="https://dart.dev/null-safety">sound null safety</a>, meaning that values can’t be null unless you say they can be. With sound null safety, Dart can protect you from null exceptions at runtime through static code analysis. Unlike many other null-safe languages, when Dart determines that a variable is non-nullable, that variable is <em>always</em> non-nullable. If you inspect your running code in the debugger, you’ll see that non-nullability is retained at runtime (hence <em>sound</em> null safety).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f00f3625ce3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter architecture!!!]]></title>
            <link>https://iampradyuman18.medium.com/flutter-architecture-a6341ce74226?source=rss-8eadd40cb00e------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6341ce74226</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[rand]]></category>
            <dc:creator><![CDATA[Pradyuman Tomar]]></dc:creator>
            <pubDate>Fri, 28 May 2021 08:31:20 GMT</pubDate>
            <atom:updated>2021-05-28T08:36:15.674Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*lQCBmQpKYMMs_k_Nvr_NIQ.png" /></figure><p>Flutter framework is open source, and has a thriving ecosystem of third-party packages that supplement the core library functionality.</p><p>This overview is divided into a number of sections:</p><ol><li>The <strong>layer model</strong>: The pieces from which Flutter is constructed.</li><li><strong>Reactive user interfaces</strong>: A core concept for Flutter user interface development.</li><li>An introduction to <strong>widgets</strong>: The fundamental building blocks of Flutter user interfaces.</li><li>The <strong>rendering process</strong>: How Flutter turns UI code into pixels.</li><li>An overview of the <strong>platform embedders</strong>: The code that lets mobile and desktop OSes execute Flutter apps.</li><li><strong>Integrating Flutter with other code</strong>: Information about different techniques available to Flutter apps.</li><li><strong>Support for the web</strong>: Concluding remarks about the characteristics of Flutter in a browser environment.</li></ol><h3>Architectural layers</h3><p>Flutter is designed as an extensible, layered system. It exists as a series of independent libraries that each depend on the underlying layer. No layer has privileged access to the layer below, and every part of the framework level is designed to be optional and replaceable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-zbt4E0rDo1d75Wz.png" /></figure><p>Typically, developers interact with Flutter through the <strong>Flutter framework</strong>, which provides a modern, reactive framework written in the Dart language. It includes a rich set of platform, layout, and foundational libraries, composed of a series of layers. Working from the bottom to the top, we have:</p><ul><li>Basic <strong>foundational</strong> classes, and building block services such as <strong>animation, painting, and gestures</strong> that offer commonly used abstractions over the underlying foundation.</li><li>The <strong>rendering layer</strong> provides an abstraction for dealing with layout. With this layer, you can build a tree of render able objects.</li><li>The <strong>widgets layer</strong> is a composition abstraction. Each render object in the rendering layer has a corresponding class in the widgets layer.</li><li>The <strong>Material</strong> and <strong>Cupertino</strong> libraries offer comprehensive sets of controls that use the widget layer’s composition primitives to implement the Material or iOS design languages.</li></ul><h3>Reactive user interfaces</h3><p>In most traditional UI frameworks, the user interface’s initial state is described once and then separately updated by user code at runtime, in response to events. One challenge of this approach is that, as the application grows in complexity, the developer needs to be aware of how state changes cascade throughout the entire UI.</p><h3>Widgets</h3><p>Widgets form a hierarchy based on composition. Each widget nests inside its parent and can receive context from the parent. This structure carries all the way up to the root widget (the container that hosts the Flutter app, typically MaterialApp or CupertinoApp)</p><h3>Composition</h3><p>Widgets are typically composed of many other small, single-purpose widgets that combine to produce powerful effects.</p><p>Where possible, the number of design concepts is kept to a minimum while allowing the total vocabulary to be large. For example, in the widgets layer, Flutter uses the same core concept (a Widget) to represent drawing to the screen, layout (positioning and sizing), user interactivity, state management, theming, animations, and navigation. In the animation layer, a pair of concepts, Animations and Tweens, cover most of the design space.</p><h3>Building widgets</h3><p>As mentioned earlier, you determine the visual representation of a widget by overriding the build() function to return a new element tree. This tree represents the widget’s part of the user interface in more concrete terms. For example, a toolbar widget might have a build function that returns a horizontal layout of some text and various buttons.</p><h3>Widget state</h3><p>The framework introduces two major classes of widget: <em>stateful</em> and <em>stateless</em> widgets.</p><p>Many widgets have no mutable state: they don’t have any properties that change over time (for example, an icon or a label). These widgets subclass StatelessWidget.</p><p>However, if the unique characteristics of a widget need to change based on user interaction or other factors, that widget is <em>stateful</em>. For example, if a widget has a counter that increments whenever the user taps a button, then the value of the counter is the state for that widget. When that value changes, the widget needs to be rebuilt to update its part of the UI. These widgets subclass StatefulWidget, and (because the widget itself is immutable) they store mutable state in a separate class that subclasses State. StatefulWidgets don’t have a build method; instead, their user interface is built through their State object.</p><p>Whenever you mutate a State object (for example, by incrementing the counter), you must call setState() to signal the framework to update the user interface by calling the State’s build method again.</p><h3>State management</h3><p>As with any other class, you can use a constructor in a widget to initialize its data, so a build() method can ensure that any child widget is instantiated with the data it</p><p>As widget trees get deeper, however, passing state information up and down the tree hierarchy becomes cumbersome. So, a third widget type, InheritedWidget, provides an easy way to grab data from a shared ancestor. You can use InheritedWidget to create a state widget that wraps a common ancestor in the widget tree.</p><h3>Rendering and layout</h3><h3>Flutter’s rendering model</h3><p>Cross-platform frameworks <em>typically</em> work by creating an abstraction layer over the underlying native Android and iOS UI libraries, attempting to smooth out the inconsistencies of each platform representation. App code is often written in an interpreted language like JavaScript, which must in turn interact with the Java-based Android or Objective-C-based iOS system libraries to display UI. All this adds overhead that can be significant, particularly where there is a lot of interaction between the UI and the app logic.</p><h3>From user input to the GPU</h3><p>The overriding principle that Flutter applies to its rendering pipeline is that <strong>simple is fast</strong>. Flutter has a straightforward pipeline for how data flows to the system, as shown in the following sequencing diagram:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gIUIxuY1bWGplvGh.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/0*VfNAIe4Rgj0Zd95c.png" /></figure><p>During the build phase, Flutter translates the widgets expressed in code into a corresponding <strong>element tree</strong>, with one element for every widget. Each element represents a specific instance of a widget in a given location of the tree hierarchy. There are two basic types of elements:</p><ul><li>ComponentElement, a host for other elements.</li><li>RenderObjectElement, an element that participates in the layout or paint phases.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZO6_o0yf3ECidzDJ.png" /></figure><p>RenderObjectElements are an intermediary between their widget analog and the underlying RenderObject, which we’ll come to later.</p><p>The element for any widget can be referenced through its BuildContext, which is a handle to the location of a widget in the tree. This is the context in a function call such as Theme.of(context), and is supplied to the build() method as a parameter.</p><h3>Layout and rendering.</h3><p>The base class for every node in the render tree is RenderObject, which defines an abstract model for layout and painting. This is extremely general: it does not commit to a fixed number of dimensions or even a Cartesian coordinate system . Each RenderObject knows its parent, but knows little about its children other than how to <em>visit</em> them and their constraints. This provides RenderObject with sufficient abstraction to be able to handle a variety of use cases.</p><p>During the build phase, Flutter creates or updates an object that inherits from RenderObject for each RenderObjectElement in the element tree. RenderObjects are primitives: RenderParagraph renders text, RenderImage renders an image, and RenderTransform applies a transformation before painting its child.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8jClczrF6BWu9U7K.png" /></figure><p>Most Flutter widgets are rendered by an object that inherits from the RenderBox subclass, which represents a RenderObject of fixed size in a 2D Cartesian space. RenderBox provides the basis of a <em>box constraint model</em>, establishing a minimum and maximum width and height for each widget to be rendered.</p><p>To perform layout, Flutter walks the render tree in a depth-first traversal and <strong>passes down size constraints</strong> from parent to child. In determining its size, the child <em>must</em> respect the constraints given to it by its parent. Children respond by <strong>passing up a size</strong> to their parent object within the constraints the parent established.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*E8hle3NKDY5iNbSH.png" /></figure><h3>Platform embedding</h3><p>The mechanism for obtaining the texture and participating in the app lifecycle of the underlying operating system inevitably varies depending on the unique concerns of that platform. The engine is platform-agnostic, presenting a stable <strong>ABI (Application Binary Interface)</strong> that provides a <em>platform embedder</em> with a way to set up and use Flutter.</p><p>Each platform has its own set of APIs and constraints. Some brief platform-specific notes:</p><ul><li>On iOS and macOS, Flutter is loaded into the embedder as a UIViewController or NSViewController, respectively. The platform embedder creates a FlutterEngine, which serves as a host to the Dart VM and your Flutter runtime, and a FlutterViewController, which attaches to the FlutterEngine to pass UIKit or Cocoa input events into Flutter and to display frames rendered by the FlutterEngine using Metal or OpenGL.</li><li>On Android, Flutter is, by default, loaded into the embedder as an Activity. The view is controlled by a FlutterView, which renders Flutter content either as a view or a texture, depending on the composition and z-ordering requirements of the Flutter content.</li></ul><h3>Integrating with other code</h3><p>Flutter provides a variety of interoperability mechanisms, whether you’re accessing code or APIs written in a language like Kotlin or Swift, calling a native C-based API, embedding native controls in a Flutter app, or embedding Flutter in an existing application.</p><h3>Platform channels</h3><p>For mobile and desktop apps, Flutter allows you to call into custom code through a <em>platform channel</em>, which is a simple mechanism for communicating between your Dart code and the platform-specific code of your host app. By creating a common channel (encapsulating a name and a codec), you can send and receive messages between Dart and a platform component written in a language like Kotlin or Swift. Data is serialized from a Dart type like Map into a standard format, and then deserialized into an equivalent representation in Kotlin (such as HashMap) or Swift (such as Dictionary).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ErfIiCJmV3cXKo8B.png" /></figure><h3>Rendering native controls in a Flutter app</h3><p>Flutter solves this by introducing platform view widgets (AndroidView and UiKitView) that let you embed this kind of content on each platform. Platform views can be integrated with other Flutter content<a href="https://flutter.dev/docs/resources/architectural-overview#a4">4</a>. Each of these widgets acts as an intermediary to the underlying operating system. For example, on Android,AndroidView serves three primary functions:</p><ul><li>Making a copy of the graphics texture rendered by the native view and presenting it to Flutter for composition as part of a Flutter-rendered surface each time the frame is painted.</li><li>Responding to hit testing and input gestures, and translating those into the equivalent native input.</li><li>Creating an analog of the accessibility tree, and passing commands and responses between the native and Flutter layers.</li></ul><h3>Hosting Flutter content in a parent app</h3><p>The converse of the preceding scenario is embedding a Flutter widget in an existing Android or iOS app. As described in an earlier section, a newly created Flutter app running on a mobile device is hosted in an Android activity or iOS UIViewController. Flutter content can be embedded into an existing Android or iOS app using the same embedding API.</p><h3>Flutter web support</h3><p>On the web, Flutter provides a reimplementation of the engine on top of standard browser APIs. We currently have two options for rendering Flutter content on the web: HTML and WebGL. In HTML mode, Flutter uses HTML, CSS, Canvas, and SVG. To render to WebGL, Flutter uses a version of Skia compiled to WebAssembly called <a href="https://skia.org/user/modules/canvaskit">CanvasKit</a>. While HTML mode offers the best code size characteristics, CanvasKit provides the fastest path to the browser’s graphics stack, and offers somewhat higher graphical fidelity with the native mobile targets<a href="https://flutter.dev/docs/resources/architectural-overview#a5">5</a>.</p><p>The web version of the architectural layer diagram is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y7ydBDiRXIg2Txen.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6341ce74226" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Common errors encounters in App Development in Flutter!]]></title>
            <link>https://iampradyuman18.medium.com/common-errors-encounters-in-app-development-in-flutter-ce28a2d76b90?source=rss-8eadd40cb00e------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce28a2d76b90</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Pradyuman Tomar]]></dc:creator>
            <pubDate>Fri, 28 May 2021 07:09:31 GMT</pubDate>
            <atom:updated>2021-05-28T07:09:31.843Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Several frequently-encountered Flutter framework errors</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*895xkwpCJOzZmptIvQYyFA.png" /></figure><h3>‘A RenderFlex overflowed…’</h3><p>RenderFlex overflow is one of the most frequently encountered Flutter framework errors, and you probably have run into it already.</p><p><strong>What does the error look like?</strong></p><p>When it happens, you’ll see yellow &amp; black stripes indicating the area of overflow in the app UI in addition to the error message in the debug console:</p><pre>The following assertion was thrown during layout:<br>A RenderFlex overflowed by 1146 pixels on the right.</pre><pre>The relevant error-causing widget was<br>    Row 	    lib/errors/renderflex_overflow_column.dart:23<br>The overflowing RenderFlex has an orientation of Axis.horizontal.<br>The edge of the RenderFlex that is overflowing has been marked in the rendering <br>with a yellow and black striped pattern. This is usually caused by the contents <br>being too big for the RenderFlex.<br>(Additional lines of this message omitted)</pre><h3>‘RenderBox was not laid out’</h3><p>While this error is pretty common, it’s often a side effect of a primary error occurring earlier in the rendering pipeline.</p><p><strong>What does the error look like?</strong></p><p>The message shown by the error looks like this:</p><pre>RenderBox was not laid out: <br>RenderViewport#5a477 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE</pre><h3>‘Vertical viewport was given unbounded height’</h3><p>This is another common layout error you could run into while creating a UI in your Flutter app.</p><p><strong>What does the error look like?</strong></p><p>The message shown by the error looks like this:</p><pre>The following assertion was thrown during performResize():<br>Vertical viewport was given unbounded height.</pre><pre>Viewports expand in the scrolling direction to fill their container. <br>In this case, a vertical viewport was given an unlimited amount of <br>vertical space in which to expand. This situation typically happens when a <br>scrollable widget is nested inside another scrollable widget.<br>(Additional lines of this message omitted)</pre><h3>‘An InputDecorator…cannot have an unbounded width’</h3><p>The error message suggests that it’s also related to box constraints, which are important to understand to avoid many of the most common Flutter framework errors.</p><p><strong>What does the error look like?</strong></p><p>The message shown by the error looks like this:</p><pre>The following assertion was thrown during performLayout():<br>An InputDecorator, which is typically created by a TextField, cannot have an <br>unbounded width.<br>This happens when the parent widget does not provide a finite width constraint. <br>For example, if the InputDecorator is contained by a `Row`, then its width must <br>be constrained. An `Expanded` widget or a SizedBox can be used to constrain the <br>width of the InputDecorator or the TextField that contains it.<br>(Additional lines of this message omitted)</pre><h3>‘Incorrect use of ParentData widget’</h3><p>This error is about missing an expected parent widget.</p><p><strong>What does the error look like?</strong></p><p>The message shown by the error looks like this:</p><pre>The following assertion was thrown while looking for parent data:<br>Incorrect use of ParentDataWidget.<br>(Some lines of this message omitted)<br>Usually, this indicates that at least one of the offending ParentDataWidgets <br>listed above is not placed directly inside a compatible ancestor widget.</pre><h3>‘setState called during build’</h3><p>The build method in your Flutter code is not a good place to call setState either directly or indirectly.</p><p><strong>What does the error look like?</strong></p><p>When the error occurs, the following message gets displayed in the console:</p><pre>The following assertion was thrown building DialogPage(dirty, dependencies: <br>[_InheritedTheme, _LocalizationsScope-[GlobalKey#59a8e]], <br>state: _DialogPageState#f121e):<br>setState() or markNeedsBuild() called during build.</pre><pre>This Overlay widget cannot be marked as needing to build because the framework <br>is already in the process of building widgets.<br>(Additional lines of this message omitted)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce28a2d76b90" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Sound null Safety in Flutter 2 and Dart 2.12?]]></title>
            <link>https://iampradyuman18.medium.com/what-is-sound-null-safety-in-flutter-2-and-dart-2-12-d40d2488de85?source=rss-8eadd40cb00e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d40d2488de85</guid>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[sound-null-safety]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Pradyuman Tomar]]></dc:creator>
            <pubDate>Fri, 28 May 2021 05:45:17 GMT</pubDate>
            <atom:updated>2021-05-28T05:45:17.905Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*lQCBmQpKYMMs_k_Nvr_NIQ.png" /><figcaption>Google Flutter 2.0</figcaption></figure><p>The Dart language now supports sound null safety!</p><p>When you opt into null safety, types in your code are non-nullable by default, meaning that variables can’t contain null <em>unless you say they can.</em> With null safety, your <strong>runtime</strong> null-dereference errors turn into <strong>edit-time</strong> analysis errors.</p><p>With null safety, all of the variables in the following code are non-nullable:</p><pre>  // In null-safe Dart, none of these can ever be null.<br>var i = 42; // Inferred to be an int.<br>String name = getFileName();<br>final b = Foo();</pre><p>To indicate that a variable might have the value null, just add ? to its type declaration:</p><pre>int? aNullableInt = null;</pre><h3>Null safety principles</h3><p>Dart null safety support is based on the following three core design principles:</p><ul><li><strong>Non-nullable by default</strong>. Unless you explicitly tell Dart that a variable can be null, it’s considered non-nullable. This default was chosen after research found that non-null was by far the most common choice in APIs.</li><li><strong>Incrementally adoptable</strong>. You choose <em>what</em> to migrate to null safety, and <em>when</em>. You can migrate incrementally, mixing null-safe and non-null-safe code in the same project. We provide tools to help you with the migration.</li><li><strong>Fully sound</strong>. Dart’s null safety is sound, which enables compiler optimizations. If the type system determines that something isn’t null, then that thing can <em>never</em> be null. Once you migrate your whole project and its dependencies to null safety, you reap the full benefits of soundness — not only fewer bugs, but smaller binaries and faster execution.</li></ul><h3>Enabling null safety</h3><p>Sound null safety is available in Dart 2.12 and Flutter 2.</p><h3>Migrating an existing package or app</h3><p>For instructions on how to migrate your code to null safety, see the <a href="https://dart.dev/null-safety/migration-guide">migration guide</a>.</p><h3>Creating a null-safe package or app</h3><p>The templates used by the dart create command and IDEs aren’t null safe yet, so you need to migrate the code they create. For example:</p><pre>$ dart create -t console-full my_cli<br>$ cd my_cli<br>$ dart migrate --apply-changes</pre><h3>Behind the scenes: SDK constraints</h3><p>To make Dart treat your code as null safe, the SDK constraints must require a language version that has null safety support. For example, your pubspec.yaml file might have the following constraints:</p><pre>environment:<br>  sdk: &quot;&gt;=2.12.0 &lt;3.0.0&quot;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d40d2488de85" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>