<?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 RAJA S on Medium]]></title>
        <description><![CDATA[Stories by RAJA S on Medium]]></description>
        <link>https://medium.com/@srajas02?source=rss-52a321830bd7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*KfiXB1LdP3l91HbO</url>
            <title>Stories by RAJA S on Medium</title>
            <link>https://medium.com/@srajas02?source=rss-52a321830bd7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 17:00:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@srajas02/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[Running a single test on Spring boot with maven commands]]></title>
            <link>https://medium.com/@srajas02/running-a-single-test-on-spring-boot-with-maven-commands-6816149b160c?source=rss-52a321830bd7------2</link>
            <guid isPermaLink="false">https://medium.com/p/6816149b160c</guid>
            <category><![CDATA[maven]]></category>
            <category><![CDATA[junit]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[RAJA S]]></dc:creator>
            <pubDate>Sun, 14 May 2023 16:38:10 GMT</pubDate>
            <atom:updated>2023-05-14T16:39:10.394Z</atom:updated>
            <content:encoded><![CDATA[<p>Today we are going to see how to run a single test at a time in Java Spring boot with maven commands. When you are working in a large projects, you might have worked on a small piece of work for that you have to improve the coverage. In this case running all the tests present in the project will be time consuming process. If you are able to run your new test cases only, it would save your time. You can run either single test class or single test method by using the below maven commands.</p><p>Lets assume that you have the following two test classes and each test class have few test methods. You can see how we are running single test class and single test method of a specific test class.</p><p><strong>MyMathTest.java</strong></p><pre>import org.example.MyMath;<br>import org.junit.Assert;<br>import org.junit.Test;<br><br>public class MyMathTest {<br>    private MyMath math = new MyMath();<br>    @Test<br>    public void Test1() {<br>        int[] numbers = {1, 2, 3};<br>        int actualResult = math.calculateSum(numbers);<br>        int expectedResult = 6;<br>        System.out.println(&quot;ggggggg&quot;);<br>        Assert.assertEquals(expectedResult, actualResult);<br>    }<br>    @Test<br>    public void Test2() {<br>        Assert.assertEquals(5, math.calculateSum(new int[] {2, 3}));<br>    }<br>} </pre><p><strong>MyCustomTest.java</strong></p><pre>import org.junit.Assert;<br>import org.junit.Test;<br><br>public class MyCustomTest {<br>    @Test<br>    public void Test1_MyMatchTest() {<br>        Assert.assertEquals(5, 5);<br>    }<br>    @Test<br>    public void Test2_MyMatchTest() {<br>        Assert.assertEquals(10, 10);<br>    }<br><br>    @Test<br>    public void Test3_MyMatchTest() {<br>        Assert.assertEquals(11, 11);<br>    }<br>}     </pre><p><strong>Command for running single test class:</strong></p><blockquote>mvn -Dtest=MyCustomTest test</blockquote><blockquote>mvn -Dtest=MyMathTest test</blockquote><p><strong>Command for running single test method:</strong></p><blockquote>mvn -Dtest=MyMathTest#Test1 test</blockquote><blockquote>mvn -Dtest=MyCustomTest#Test2_MyMatchTest test</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BKWNSOh_XCFdIMyrqr3M_Q.png" /></figure><p><strong>Conclusion:</strong></p><p>Thanks for reading! I hope this blog might be helpful!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6816149b160c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Merge two objects deeply nested in Javascript]]></title>
            <link>https://medium.com/@srajas02/merge-two-objects-deeply-nested-in-javascript-8e8515b4f8d3?source=rss-52a321830bd7------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e8515b4f8d3</guid>
            <dc:creator><![CDATA[RAJA S]]></dc:creator>
            <pubDate>Sat, 17 Sep 2022 09:55:44 GMT</pubDate>
            <atom:updated>2022-11-18T15:55:21.764Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, you will learn how two objects can be merged deeply nested objects. Javascript is offering <strong>Object.assign()</strong> and <strong>Spread Operator</strong> to merge the objects. But they does merge objects shallow only not deeply.</p><p>I have found a solution for merging deeply nested objects with the recursive function.</p><p><strong>Recursion</strong></p><p>Recursive function calls itself until condition met</p><p><strong>Recursion Example:</strong></p><pre>const factorial = (n) =&gt; {<br>  if (n === 0) {<br>    return 1;<br>  } else {<br>    return n * factorial(n - 1);<br>  }<br>};<br>console.log(factorial(10)); </pre><p><strong>Merge nested objects deeply:</strong></p><p>I have created a function named <strong>deepMergeObject</strong> and It has two parameters called <strong>targetObject and sourceObject</strong>. To avoid the mutation, I have cloned deeply both objects with the help of JSON.parse and JSON.stringify.</p><p><strong>Iterating the sourceObject, when the property value is other than object type, It will be merged into the targetObject. If the property value is object type, we are invoking the deepMergeObject function recursively.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fWY-tsPSb3oaKRbR_HH2Nw.png" /></figure><p>we have created two objects named <strong>targetPerson and sourcePerson</strong>. Whatever properties we are passing into the sourcePerson, it will be merged into the targetPerson.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xjW5nbzivoWiBnw4fHDczw.png" /></figure><p>We have passed airlines and jobs nested properties in the sourcePerson. You can see below how our deepMergeFunction merged two objects very nicely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ORANEaBrMQpbp0UbKOHXuA.png" /></figure><p><strong>Code Snippets</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b3ea95715c99b6bae93707ad3d23a666/href">https://medium.com/media/b3ea95715c99b6bae93707ad3d23a666/href</a></iframe><p><strong>Conclusion:</strong></p><p>I hope this blog would help you when you are working on merging two objects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e8515b4f8d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter styling tricks]]></title>
            <link>https://medium.com/@srajas02/flutter-styling-tricks-3192907f56e3?source=rss-52a321830bd7------2</link>
            <guid isPermaLink="false">https://medium.com/p/3192907f56e3</guid>
            <category><![CDATA[flutter-text-style]]></category>
            <category><![CDATA[flutter-css-styling]]></category>
            <dc:creator><![CDATA[RAJA S]]></dc:creator>
            <pubDate>Sat, 21 Mar 2020 14:20:24 GMT</pubDate>
            <atom:updated>2020-03-21T16:59:59.451Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter styling tricks for beginners</h3><p>When I started to work in the flutter, I have repeated the same text style in a different place all over my app. This was annoying me and my code lost readability. I decided to find a solution. The solution is to keep all the text style into a commonplace like all we do in CSS. I wish to share that solution with you all, I hope it will help you.</p><p>See the below image, we have header, body, and footer. The text style of the body is the same as the header except for the font size and underline. We have a button as separate components. Let&#39;s see how to share the styles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*Ptel01W7m4nb7jcP9lXt9Q.png" /></figure><p>First, create a folder <strong><em>styles/</em></strong><em> </em>into <strong><em>lib/</em></strong> folder. Then create two files <strong><em>styles.dart</em></strong><em> </em>and <strong><em>utils.dart </em></strong>into the styles/ folder.</p><p>SASS has <strong><em>@extend</em> </strong>for<strong> </strong>one selector should inherit the styles of another. Like that, we have written extend() utils for inheriting the styles from one variable into another with the help dart <em>merge() </em>method</p><p>utils.dart</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*6U84ZKoJMEQjFBkB67Iy6w.png" /><figcaption>extend util</figcaption></figure><p>I have inherited all styles of the headerStyle. Here I have ovveride the fontSize and added one new property decoration in the bodyStyle.</p><p>styles.dart</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zaIpQHlOQmd8vOOoouvGCQ.png" /></figure><p>Next, import these styles into <strong><em>main.dart</em></strong> and start to use inside the header, body, and button.</p><p>main.dart</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6YPzZHtoibbJ3eV2S1RE5Q.png" /></figure><p>Conclusion:</p><p>I demonstrated with a simple example. I am pretty sure, This approach will improve your code readability and maintainability. I hope, you have liked this tutorial.</p><p>Source Code: <a href="https://github.com/srajas0/flutter-text-styling-tricks">https://github.com/srajas0/flutter-text-styling-tricks</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3192907f56e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ember Form Validation with ember-cp-validations]]></title>
            <link>https://medium.com/@srajas02/ember-form-validation-with-ember-cp-validations-724afcb95b49?source=rss-52a321830bd7------2</link>
            <guid isPermaLink="false">https://medium.com/p/724afcb95b49</guid>
            <category><![CDATA[ember-cp-validations]]></category>
            <category><![CDATA[ember-form]]></category>
            <category><![CDATA[ember-form-validation]]></category>
            <dc:creator><![CDATA[RAJA S]]></dc:creator>
            <pubDate>Fri, 13 Mar 2020 04:47:30 GMT</pubDate>
            <atom:updated>2020-03-13T05:09:47.942Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, We are going to do a simple registration form and how to validate it with ember-cp-validations. <a href="https://github.com/srajas0/ember-form-validation">source code</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*MQ1jw6QEx6enrWhcx7VFQQ.png" /></figure><p>All application requires a form. It may be used for Registration, Login or anything. We should have to validate the information entered by the user. Validation is a big deal for every developer.</p><p>Let’s take a simple registration form and which contains three mandatory fields such as the name, email, and mobile number. We have to check the following conditions</p><ol><li>Check whether all the fields are not empty.</li><li>The name field should not have any numbers.</li><li>Email is valid or not</li><li>Mobile Number is at least having 10 digits.</li></ol><p>For three fields you can write the validation logic into a function and keep it clean. Just imagine, If your form has more than 10 fields, the function size will grow up and become complex.</p><p>There is an ember addon that is a rescue. Which name is <a href="https://github.com/offirgolan/ember-cp-validations">ember-cp-validations</a>. <strong><em>We can do validation of the form as configurable</em></strong> with this addon. You don’t have to write any <em>if condition or switch statement.</em></p><p>Let&#39;s start to create the form. First, create an app and install the addon into the application as a dependency in the terminal.</p><pre>// create an application<br>ember new form-validation</pre><pre>// install the ember-cp-validations<br>ember install ember-cp-validations</pre><p>Create a route and controller named registration-form.</p><pre>ember g route registration-form</pre><pre>ember g controller registration-form</pre><p>Create a component named text-input</p><pre>ember g component text-input</pre><p>Create a user model</p><pre>&gt;&gt;&gt; ember g model user</pre><pre>export default DS.Model.extend(Validations, {</pre><pre>  name: DS.attr(&#39;string&#39;),</pre><pre>  email: DS.attr(&#39;string&#39;),</pre><pre>  mobileNumber: DS.attr(&#39;string&#39;)</pre><pre>});</pre><p>Now we have created a user model with three attributes. We have to insert validations of each model attribute here. ember-cp-validations provide some default validators <strong><em>presence, format, length, date </em></strong>…etc; You can create your own custom validator too. <a href="https://offirgolan.github.io/ember-cp-validations/docs/classes/Custom.html">https://offirgolan.github.io/ember-cp-validations/docs/classes/Custom.html</a>.</p><p>Let’s see the below code, we can realize the amazing power of ember-cp-validations addon.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe080f17e2c26a9b866bb63a532de204/href">https://medium.com/media/fe080f17e2c26a9b866bb63a532de204/href</a></iframe><p>We have done the validation as configurable. You might save this into a separate JSON file If your model will grow up in the future.</p><p>Next, we have to do create a record into the model hook of the router. Pass the model into the text-input component. When a user clicks on the submit and reset button, the controller&#39;s actions will be triggered.</p><pre><strong>app/routes/registration-form.js</strong></pre><pre>import Route from &#39;@ember/routing/route&#39;;</pre><pre>export default Route.extend({</pre><pre> model() {</pre><pre>  return this.store.createRecord(&#39;user&#39;);</pre><pre> },</pre><pre>});</pre><pre><strong>app/controllers/registration-form.js</strong></pre><pre>import Controller from &#39;@ember/controller&#39;;</pre><pre>export default Controller.extend({</pre><pre>  showError: false,</pre><pre>  actions: {<br>   reset(model) {</pre><pre>     model.rollbackAttributes();</pre><pre>   },</pre><pre>  submit(model) {</pre><pre>    this.set(&#39;showError&#39;, true);</pre><pre>    if (model.get(&#39;validations&#39;).isValid) {</pre><pre>      this.model.save();</pre><pre>    }</pre><pre>  }</pre><pre>}</pre><pre>});</pre><p><strong>templates/registration-form.hbs</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40ec85f964928dc7bb40ad5ab4b481ec/href">https://medium.com/media/40ec85f964928dc7bb40ad5ab4b481ec/href</a></iframe><p>We have to do field level validation in the component level When a user is focused out from the textbox.</p><p><strong>components/text-input.js</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/599c896143c4e862d6bf3bf52763dd41/href">https://medium.com/media/599c896143c4e862d6bf3bf52763dd41/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/872bc1ed20b4ce3357cc577fb43538c3/href">https://medium.com/media/872bc1ed20b4ce3357cc577fb43538c3/href</a></iframe><p>Conclusion:</p><p>I hope, you wondered the amazing power of ember-cp-validations. How it is efficient and saves a lot of repeated work for form validation.</p><p>Thanks for reading!</p><p>Source Code <a href="https://github.com/srajas0/ember-form-validation">https://github.com/srajas0/ember-form-validation</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=724afcb95b49" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ember Test Case for a CRUD Application with mirage]]></title>
            <link>https://medium.com/@srajas02/ember-test-case-for-a-crud-application-with-mirage-d6d9836bfee2?source=rss-52a321830bd7------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6d9836bfee2</guid>
            <category><![CDATA[ember-uni-testing]]></category>
            <category><![CDATA[ember-testing]]></category>
            <category><![CDATA[ember-data-testing]]></category>
            <category><![CDATA[ember-inegration-testing]]></category>
            <dc:creator><![CDATA[RAJA S]]></dc:creator>
            <pubDate>Wed, 04 Mar 2020 16:51:06 GMT</pubDate>
            <atom:updated>2020-03-05T02:24:18.060Z</atom:updated>
            <content:encoded><![CDATA[<p>I have been working in emberjs since 2018. I felt, Ember does not have enough documentation and contributions to open source communities such as StackOverflow, Github compare with other javascript frameworks.</p><p>I realized many developers are looking for examples of ember tests. In this tutorial, I have covered how to write <strong><em>UNIT, Acceptance and Integration </em></strong>test for an ember application. I will demonstrate with a CRUD application example. I have assumed that you are already familiar with the mirage and basics of ember testing. So this tutorial will have only examples rather than theoretical explanations.</p><p><strong>Required Dependencies:</strong></p><ul><li>ember install ember-cli-mirage (Used to mock the back end API call)</li><li>ember install ember-cli-code-coverage</li><li><a href="https://github.com/simplabs/qunit-dom">qunit-dom</a></li><li>ember-qunit</li></ul><p><strong>ember-cli-mirage</strong></p><p>If you are going to write the test case for any ember addons, the mirage should be residing inside the tests folder dummy app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*UwTaiKDqFgFwGX416g4_gw.png" /></figure><p><strong>ember-cli-code-coverage</strong></p><p>This addon will be useful to see the result of your code coverage. After installing this addon you will have to change the <em>testem.js</em> file of your application in the following way. Click this link <a href="https://github.com/srajas0/ember-test-cases/blob/master/testem.js"><strong>testem.js</strong></a></p><p>Coverage will only be generated when an environment variable is true (by default COVERAGE) and running your test command like normal.</p><pre>COVERAGE=true ember test -s</pre><p>After tunning this command, the coverage folder will be created in the root folder of your application. open <strong><em>coverage/index.html </em></strong><em>in your browser and you can see the coverage of all files as in the below screenshot.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qv308-MdyBXU7-P-ueGC1g.png" /></figure><p><strong>CRUD Application</strong></p><p>To get started clone the following application from my GitHub . Click the link <a href="https://github.com/srajas0/ember-test-cases">CRUD Application</a>. Run the below command to see the test cases</p><pre>COVERAGE=true ember test -s</pre><p>Once you run the application and you will see the app <em>as in the below screenshot</em></p><pre>ember s</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TkDf2Kwu06lI45JHskoyDA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_-KlZDVy_Ny8z_S0D7v8oQ.png" /></figure><p>Our Application has two routes(#/users-list and #/create-user). Let&#39;s start to write the test case.</p><p><strong>Acceptance Test</strong></p><p>We should test the application flow from user’s perception, which is called the acceptance test. Following items are our application flow</p><ol><li>When a user opens the application, he will be redirected to the <em>/users-list page from the index route.</em></li></ol><p><strong>routes/index.js</strong></p><pre>beforeModel() {</pre><pre>  this.replaceWith(&#39;users-list&#39;);</pre><pre>}</pre><p>2. When a user clicks on the Create User button in <em>/users-list</em>, It will be redirected to <em>/create-user</em> page.</p><p>3. After the user fills the form, clicks on the “Create User” button, we should redirect to <em>/users-list</em> page.</p><p>These three flows are covered in our Acceptance test. Please refer the following files</p><p><strong>acceptance/users-list.js</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/69eed8481107c0e90dc769211e5f5c30/href">https://medium.com/media/69eed8481107c0e90dc769211e5f5c30/href</a></iframe><p><strong>acceptance/create-user-test.js</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/118b66c82830d12da4a61a46473ef21e/href">https://medium.com/media/118b66c82830d12da4a61a46473ef21e/href</a></iframe><p>We have covered all the flows in our application test. Next we are going to see, UNIT test.</p><p><strong>UNIT Test for routes:</strong></p><p>routes unit test should be covered the following items.</p><ol><li>Check whether the route model has been loaded or not.</li><li>Test all the actions of routes</li><li>Test all the functions of routes.</li></ol><p><strong>unit/routes/users-list-test.js</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0316519dbc4a9b645cbb524de67edffd/href">https://medium.com/media/0316519dbc4a9b645cbb524de67edffd/href</a></iframe><p><strong>unit/routes/create-user-test.js</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/98e746c46e6b9cc4cf9350093c52fe1d/href">https://medium.com/media/98e746c46e6b9cc4cf9350093c52fe1d/href</a></iframe><p><strong>unit test for adapters</strong></p><p>In our CRUD application, user model’s adapter is using the different endpoint for urlForFindAll() and urlForDeleteRecord().</p><p><strong>app/adapters/user.js</strong></p><pre>urlForFindAll() {</pre><pre>  return this._super(...arguments) + &#39;/findAll&#39;;</pre><pre>},</pre><pre>urlForDeleteRecord() {</pre><pre>  return this._super(...arguments) + &#39;/destroy&#39;;</pre><pre>}</pre><p>We should test this in the following way.</p><p><strong>unit/adapters/user-test.js</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c1bc0ee121bb7463ef442a5323def5da/href">https://medium.com/media/c1bc0ee121bb7463ef442a5323def5da/href</a></iframe><p><strong>Integration Test</strong></p><p>The following items should be covered in the integration test of a component.</p><ol><li>All actions should be tested.</li><li>Test any conditional rendering in the templates. Refer to our <em>textbox-input.hbs</em></li></ol><pre>{{#if showError}}</pre><pre>  &lt;div class=&quot;field-error&quot;&gt;</pre><pre>    {{v-get model errorProp &quot;message&quot;}}</pre><pre> &lt;/div&gt;</pre><pre>{{/if}}</pre><p>3. All the private functions of the component.</p><p>I have a calculator component in our application for the learning purpose of integration testing.</p><p><strong>integration/components/calc-test.js</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c64a837bb1c36052c7160e54ddaef86f/href">https://medium.com/media/c64a837bb1c36052c7160e54ddaef86f/href</a></iframe><p>Conclusion:</p><p>I have finished my tutorial. I hope, you enjoyed this tutorial. Thanks for reading!</p><p>Example Source Code <a href="https://github.com/srajas0/ember-test-cases">https://github.com/srajas0/ember-test-cases</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6d9836bfee2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LoadingIndicator with the stacked layout on flutter]]></title>
            <link>https://medium.com/@srajas02/loadingindicator-with-the-stacked-layout-on-flutter-82d717624821?source=rss-52a321830bd7------2</link>
            <guid isPermaLink="false">https://medium.com/p/82d717624821</guid>
            <category><![CDATA[flutter-loadingindicator]]></category>
            <category><![CDATA[circularprogressindicator]]></category>
            <category><![CDATA[flutter-progressindicator]]></category>
            <category><![CDATA[flutter-stack-layout]]></category>
            <dc:creator><![CDATA[RAJA S]]></dc:creator>
            <pubDate>Sat, 29 Feb 2020 17:25:17 GMT</pubDate>
            <atom:updated>2020-02-29T17:25:17.594Z</atom:updated>
            <content:encoded><![CDATA[<p>In this tutorial, You will learn how to show Loadingindicator, When a user waiting for a response after clicking on a button. In this example, We are going to implement two types of Loading indicators. They are</p><ul><li>Loading indicator with a custom image</li><li>Loading indicator with Flutter’s CircularProgressIndicator</li></ul><p><strong>What is Stacked Layout?</strong></p><p>Use <a href="https://api.flutter.dev/flutter/widgets/Stack-class.html">Stack</a> to arrange widgets on top of a base widget — often an image. The widgets can completely or partially overlap the base widget. Visit <a href="https://flutter.dev/docs/development/ui/layout#stack">the Flutter’s example to a better understanding</a>.</p><p><strong>Loading indicator with a custom image</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6hzye9owCuvFv8iYkU02Mg.png" /></figure><p>First step is, you have to add a <strong>spinner.gif </strong>image into the <em>/assets</em> folder and mentioned the path of the image in <strong><em>pubspec.yaml</em></strong><em>. </em>you can get the image from my GitHub source code. Then you have to create a separate component for LoadingIndicator which name is <em>loader.dart</em>.</p><p><strong>loader.dart</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7abdb96e4736137c96f85a316b68f8e3/href">https://medium.com/media/7abdb96e4736137c96f85a316b68f8e3/href</a></iframe><p>Loader widget is StatelessWidget. I have used <strong><em>ModalBarrier</em></strong> component for the overlay of the screen. As we saw earlier, The stacked layout contains multiple children widgets and arrange widgets on top of a base widget.</p><p>In our widget, the overlay will be at the bottom and the <strong><em>spinner</em></strong> image will be at the top. We have created a loader widget is configurable. You can pass any kind of loading text, overlay opacity ...etc; and even you can make it the image name also configurable.</p><p>Now we want to call the Loader widget from the home page. The <strong><em>_MyHomePageState</em></strong> widget will have an <strong><em>_isLoading</em></strong> property. This state will be changed when you click on the <strong><em>Loading Button. </em></strong>I am using <strong><em>Future.delayed </em></strong>function for mock asynchronous.</p><p><strong>main.dart</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7272db5a55e64573dfc707890a564046/href">https://medium.com/media/7272db5a55e64573dfc707890a564046/href</a></iframe><p>We have finished the loading indicator with a custom image. Next, we are going to see Loading indicator with Flutter’s CircularProgressIndicator.</p><p><strong>Loading indicator with Flutter’s CircularProgressIndicator</strong></p><p>We have already done our widget is configurable. So this part will requires a few minor changes only. You have to add a new property <em>isCustom. </em>If this property is false, we have to show the <strong>CircularProgressIndicator. </strong>See the changes below in the Loader widget</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/14e9690b74693f8dea217b1527dac627/href">https://medium.com/media/14e9690b74693f8dea217b1527dac627/href</a></iframe><p>When you want to show the Flutter’s CircularProgressIndicator, you just need to pass <em>isCustom</em> property as false while you calling the <strong>Loader</strong> widget as you can seen in below.</p><pre>Loader(isCustom: false, loadingTxt: &#39;Content is loading...&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5KbXpvAimMNNWadT9GTfCA.png" /></figure><p><strong>Conclusion</strong></p><p>We have seen how to show Loadingindicator and I hope, you enjoyed this tutorial. Thanks for reading!</p><p>Source Code <a href="https://github.com/srajas0/flutter-loading-indicator">https://github.com/srajas0/flutter-loading-indicator</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82d717624821" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>