<?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 Sadiasaif Official on Medium]]></title>
        <description><![CDATA[Stories by Sadiasaif Official on Medium]]></description>
        <link>https://medium.com/@sadiasaif.official?source=rss-9f8a575577cb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FAYPPd-adnfzq5ufa9QmgA@2x.png</url>
            <title>Stories by Sadiasaif Official on Medium</title>
            <link>https://medium.com/@sadiasaif.official?source=rss-9f8a575577cb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 26 May 2026 23:03:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sadiasaif.official/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[Flutter: Toggle Show Hide Password]]></title>
            <link>https://medium.com/@sadiasaif.official/flutter-toggle-show-hide-password-8ecc0ccdddb7?source=rss-9f8a575577cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ecc0ccdddb7</guid>
            <category><![CDATA[getx]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[toogle-password]]></category>
            <category><![CDATA[widget]]></category>
            <dc:creator><![CDATA[Sadiasaif Official]]></dc:creator>
            <pubDate>Mon, 31 Oct 2022 17:59:08 GMT</pubDate>
            <atom:updated>2022-10-31T17:59:08.363Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*7ADXC_iPfQaWx_Zd.png" /></figure><blockquote><em>This article was originally written by </em><a href="https://medium.com/@sadiasaif.official">@sadiasaif.official</a></blockquote><p>I know all you know about this feature which toggles the password show and hide. This is super cool because sometimes we want to see the password anyway.</p><p>Sometimes we get so frustrated while filling the form that we wanted to what password I am filling in and why the app is not accepting my password.</p><h3>Get Started</h3><p>I am going to start from scratch which means you can copy and past the code in your brand new project and it will work.</p><p>The AIM of this article is to teach you how to make a show/hide password button with Input Field and make it work. Also, make you understand the Logic and implementation behind that.</p><h3>Step 1</h3><p>Here is my main.dart file where you can see I have removed all the boilerplate code. I have written everything from scratch for your better understanding.</p><p>I am trying to keep it as simple as I could. So, we can only focus on the actual thing and No new things will come in between.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:demo_app/login.dart&#39;;   // I will create this fill in stepvoid main() {<br>  runApp(MyApp());<br>}class MyApp extends StatelessWidget {<br>  <a href="http://twitter.com/override">@override</a><br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      home: LoginForm(),    // This will widget will be created in next step<br>    );<br>  }<br>}</pre><blockquote><em>You will get two error in this file and both will be fixed in next step. We will fix them by creating a new file (login.dart) which will contain LoginForm Widget code.</em></blockquote><p>I don’t want to bring you back to this file aging that why I added those lines also which throws an error.</p><h3>Step 2</h3><p>This step will create a file login.dart and this file will have StatefulWidget called LoginForm. I will keep this widget very so simple and try to make you understand the logic behind the show/hide password.</p><h3>Working Principle</h3><p>Input filed and password input fields are the same except for one arguments (obscureText).</p><p>obscureText: This argument gives us the power to hide the data entered in the input field. The default of this is false, which makes it visible to us. If we make this true, the actual text will be invisible.</p><pre>import &#39;package:flutter/material.dart&#39;;class LoginForm extends StatefulWidget {<br>  <a href="http://twitter.com/override">@override</a><br>  _LoginFormState createState() =&gt; _LoginFormState();<br>}class _LoginFormState extends State&lt;LoginForm&gt; {<br>  bool _isHidden = true;<a href="http://twitter.com/override">@override</a><br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      backgroundColor: Theme.of(context).secondaryHeaderColor,<br>      body: Center(<br>        child: TextField(<br>            obscureText: _isHidden,<br>            decoration: InputDecoration(<br>                hintText: &#39;Password&#39;,<br>            ),    <br>        ),<br>      ),<br>    );<br>  }<br>}</pre><h3>Step 3</h3><p>In this step, we will add a button at the end of the field. Luckily there is a suffix property in flutter which helps us in add widget to the end.</p><blockquote><em>We can do a lot using that suffix icon i.e When you change username in Instagram, You see there is check box which in text field, that indicated if the username is available or not.</em></blockquote><pre>import &#39;package:flutter/material.dart&#39;;class LoginForm extends StatefulWidget {<br>  <a href="http://twitter.com/override">@override</a><br>  _LoginFormState createState() =&gt; _LoginFormState();<br>}class _LoginFormState extends State&lt;LoginForm&gt; {<br>  bool _isHidden = true;<a href="http://twitter.com/override">@override</a><br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      backgroundColor: Theme.of(context).secondaryHeaderColor,<br>      body: Center(<br>        child: TextField(<br>            obscureText: _isHidden,<br>            decoration: InputDecoration(<br>                hintText: &#39;Password&#39;,<br>                suffix: Icon(Icons.visibility),<br>            ),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><h3>Step 4</h3><p>This is the magical step where all the magic is going to happen. We will make the icon clickable and see/hide the password.</p><p>Now I will wrap the icon with InkWell which will make it clickable. So, when we will click on that it will toggle the obscureText the argument between true and false.</p><pre>import &#39;package:flutter/material.dart&#39;;class LoginForm extends StatefulWidget {<br>  <a href="http://twitter.com/override">@override</a><br>  _LoginFormState createState() =&gt; _LoginFormState();<br>}class _LoginFormState extends State&lt;LoginForm&gt; {<br>  bool _isHidden = true;<a href="http://twitter.com/override">@override</a><br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      backgroundColor: Theme.of(context).secondaryHeaderColor,<br>      body: Center(<br>        child: TextField(<br>            obscureText: _isHidden,<br>            decoration: InputDecoration(<br>                hintText: &#39;Password&#39;,<br>                suffix: InkWell(<br>                    onTap: _togglePasswordView,<br>                    child: Icon( Icons.visibility),<br>                ),<br>            ),<br>        ),<br>      ),<br>    );<br>  }void _togglePasswordView() {<br>    setState(() {<br>      _isHidden = !_isHidden;<br>    });<br>  }<br>}</pre><p>If you are not familiar with this code then this might be an interesting logic for you. This code basically changes the by adding not it’s original value.</p><p>Suppose the _isHidden is true then when we add !(exclamation) before it then it will make it false. As the programming fundamental, we store the value of the right-hand side into the left hand side.</p><p>So technically we are toggling the value between true and false using an exclamation mark.</p><pre>void _togglePasswordView() {<br>    setState(() {<br>        _isHidden = !_isHidden;<br>    });<br>}</pre><h3>Step 5 — Final</h3><p>In this step, I will update the icon of the suffix. I mean to say when the password is visible we want to show visibility hide/off icon and when the password is hidden we want to show visibility on icon.</p><pre>import &#39;package:flutter/material.dart&#39;;class LoginForm extends StatefulWidget {<br>  <a href="http://twitter.com/override">@override</a><br>  _LoginFormState createState() =&gt; _LoginFormState();<br>}class _LoginFormState extends State&lt;LoginForm&gt; {<br>  bool _isHidden = true;<a href="http://twitter.com/override">@override</a><br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      backgroundColor: Theme.of(context).secondaryHeaderColor,<br>      body: Center(<br>        child: TextField(<br>            obscureText: _isHidden,<br>            decoration: InputDecoration(<br>            hintText: &#39;Password&#39;,<br>            suffix: InkWell(<br>                onTap: _togglePasswordView,<br>                child: Icon(<br>                        _isHidden <br>                        ? Icons.visibility <br>                        : Icons.visibility_off,<br>                    ),<br>                ),<br>            ),<br>        ),<br>      ),<br>    );<br>  }void _togglePasswordView() {<br>    setState(() {<br>      _isHidden = !_isHidden;<br>    });<br>  }<br>}</pre><h3>Conclusion</h3><p>I hope you got the complete logic and implementation. I tried to break it into small parts and tried to add some code in each step. This helps entry-level developers a lot in understanding. I also added the same code in each step because sometimes entry-level developers face problems in understanding.</p><p>When I was an entry-level developer, I faced a lot of difficulties but somehow I almost covered the hard path, and today sharing them in easy language.</p><p>Thanks</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ecc0ccdddb7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Make text styling more effective with RichText widget]]></title>
            <link>https://medium.com/@sadiasaif.official/make-text-styling-more-effective-with-richtext-widget-7f2b7a89865?source=rss-9f8a575577cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f2b7a89865</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[rich-text]]></category>
            <category><![CDATA[widget]]></category>
            <dc:creator><![CDATA[Sadiasaif Official]]></dc:creator>
            <pubDate>Fri, 17 Jun 2022 06:58:40 GMT</pubDate>
            <atom:updated>2022-06-17T06:58:40.980Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*z55SxW6qaTd54toB.jpeg" /></figure><p>As the name suggests, RichText provides more options to the way a text is displayed on the screen.</p><p>The style property of text widget is used to apply various styles to a text, but a limitation of it is, the style gets applied to the entire text irrespective of whether the text is a single line or multiline. Consider below snippet to render a single line of text on screen:</p><pre>Container(<br>    padding: EdgeInsets.all(10),<br>    child: Center(<br>        child: Text(<br>          <strong>&#39;The future belongs to those who prepare for it today.&#39;</strong>)<br>    )<br>)</pre><p>With above code, if we apply fontSize as 20, fontStyle as italic, the style will be applied to entire text, as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/0*O0SbSTk-GsTqlCD8.png" /></figure><p>But, what if, we only want to <em>underline</em> a word from above text or show certain words of text as <em>bold/italic</em> or in <em>different color </em>and rest of the text as normal text?</p><p>RichText widget helps to answer and achieve the above cases.</p><p><strong>RichText structure</strong></p><p>RichText uses TextSpan as a <em>parent</em> object that has its own style property along with a text parameter which we can input the actual text. The parent object then can have a number of TextSpan objects as <em>children</em> who have their own style property that can be applied to respective text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/207/0*JRCC-aby3FWab31e.png" /></figure><p>With above basic overview of RichText widget, let’s now see how we can make use of this widget in realtime.</p><p><strong>Use case 1:</strong></p><p>Most of the apps have login screen and an option to create an account. The create account section is usually a combination of regular text followed by colored text, like <a href="https://stackoverflow.com/users/login?ssrc=head&amp;returnurl=https%3a%2f%2fstackoverflow.com%2f"><strong>StackOverflow</strong></a> login screen as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/0*UWf6JpMyA0BVj32r.png" /></figure><p>The text Don&#39;t have an account? Sign up is a single line text, with last part of it being a clickable word to take user towards their sign up screen.</p><p><strong>Approach</strong></p><p>We’ll divide the text into <em>two parts.</em> In the first part, we’ll use the parent TextSpan object and will input the regular text Don&#39;t have an account? with the color property as Colors.black.</p><pre>child: Center(<br>  child: RichText(<br>    text: TextSpan(<br>      text: <strong>&#39;Don\&#39;t have an account?&#39;</strong>, style: TextStyle(color: Colors.<em>black</em>, fontSize: 18),</pre><p>In the second part, we’ll use children objects of TextSpan to input text Sign up and pass the color property as Colors.blue</p><pre>children: &lt;TextSpan&gt;[<br>  TextSpan(text: <strong>&#39; Sign up&#39;</strong>, style: TextStyle(color: Colors.<em>blueAccent</em>, fontSize: 18)<br>      )<br>]</pre><p>The output is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/0*a_ecQe7sj8LvpfHw.png" /></figure><p>Another cool thing about using RichText widget is that, the TextSpan the object comes with their own TapGestureRecognizer() which helps to implement onTap() action on specific parts of the text as needed. In our example, since the user can tap on Sign up text to navigate to the desired screen, we’ll make use of recognizer property that makes the text tappable, as shown in the entire code snippet below:</p><blockquote><em>Note: Before using </em><em>TapGestureRecognizer() , we’ll need to </em><strong><em>import ‘package:flutter/gestures.dart’</em></strong><em>;</em></blockquote><pre>Container(<br>    padding: EdgeInsets.all(10),<br>    child: Center(<br>      child: RichText(<br>        text: TextSpan(<br>            text: <strong>&#39;Don\&#39;t have an account?&#39;</strong>,<br>            style: TextStyle(<br>                color: Colors.<em>black</em>, fontSize: 18),<br>            children: &lt;TextSpan&gt;[<br>              TextSpan(text: <strong>&#39; Sign up&#39;</strong>,<br>                  style: TextStyle(<br>                      color: Colors.<em>blueAccent</em>, fontSize: 18),<br>                  recognizer: TapGestureRecognizer()<br>                    ..<strong>onTap </strong>= () {<br>                      <em>// navigate to desired screen<br>                    </em>}<br>              )<br>            ]<br>        ),<br>      ),<br>    )<br>)</pre><p>By using recognizer property, we won’t need to wrap RichText widget with another widget such as GestureDetector to expose and use tap() for navigation.</p><p><strong>Use Case 2:</strong></p><p>Just like sign up section as we saw above, there is also a section to display user agreement in various login screens, like <a href="https://www.xoom.com/sign-in"><strong>Xoom</strong></a> (an online money transfer app) has below UI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/0*FCk4D775eDoRc91Q.png" /></figure><p>To implement last section, we can divide the text into three parts as below:</p><ul><li><strong>First part :</strong> parent TextSpan with text (By Logging In,) and style (Colors.black)</li></ul><pre>child: RichText(<br>  text: TextSpan(<br>      text: <strong>&#39;By Logging In,&#39;</strong>,<br>      style: TextStyle(<br>          color: Colors.<em>black</em>, fontSize: 15),</pre><ul><li><strong>Second part:</strong> first of children of TextSpan object with text(you accept the Xoom) and style (Colors.black)</li></ul><pre>children: &lt;TextSpan&gt;[<br>  TextSpan(text: <strong>&#39; you accept the Xoom&#39;</strong>,<br>      style: TextStyle(<br>          color: Colors.<em>black</em>, fontSize: 15)<br>  ),</pre><ul><li><strong>Third part:</strong> second of children of TextSpan object with text(User Agreement) and style (Colors.blue and fontWeight as bold) and recognizer to tap.</li></ul><pre>TextSpan(<br>    text: <strong>&#39; User Agreement&#39;</strong>,<br>    style: TextStyle(color: Colors.<em>blueAccent</em>, fontWeight: FontWeight.<em>bold</em>),<br>  recognizer: TapGestureRecognizer()<br>    ..<strong>onTap </strong>= () {<br>      <em>// navigate to desired screen<br>    </em>}<br>)</pre><p>Output is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/0*zO3UjawB5z99jemD.png" /></figure><p><strong>Use Case 3:</strong></p><p>Here, we’ll make use of multiline text/paragraph that will have some of the words underlined with a different color. Consider <a href="https://github.com/"><strong>github</strong></a> login screen which has a text paragraph as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/0*TNNqv7aDdk2A7YOA.png" /></figure><p><strong>Approach</strong></p><p>Since the text apart from open source and business are straightforward plain text, we’ll focus on implementing only the above words and not regular text.</p><p>Inside TextSpan object, we’ll use style property and assign a <em>white</em> color to open source and business terms respectively along with TextDecoration.underline to achieve the expected style, as shown below:</p><pre>TextSpan(text: <strong>&#39;open source&#39;</strong>,<br>    style: TextStyle(<br>        color: Colors.<em>white</em>, fontSize: 20, fontWeight: FontWeight.<em>bold</em>, decoration: TextDecoration.<em>underline</em>),<br>  recognizer: TapGestureRecognizer()<br>    ..<strong>onTap </strong>= () {<br>     <em>// open desired screen<br>    </em>}<br>),TextSpan(<br>  text: <strong>&#39;business,&#39;</strong>,<br>    style: TextStyle(<br>        color: Colors.<em>white</em>, fontSize: 20, fontWeight: FontWeight.<em>bold</em>, decoration: TextDecoration.<em>underline</em>),<br>    recognizer: TapGestureRecognizer()<br>      ..<strong>onTap </strong>= () {<br>        <em>// open desired screen<br>      </em>}<br>),</pre><p>The entire code snippet is as below:</p><pre>Container(<br>    color: Colors.<em>black</em>,<br>    padding: EdgeInsets.all(10),<br>    child: Center(<br>        child: RichText(<br>          text: TextSpan(<br>              text: <strong>&#39;GitHub is a development platform inspired by the way you work. From &#39;</strong>,<br>              style: TextStyle(<br>                  color: Colors.<em>grey</em>,<br>                  fontSize: 20,<br>                  fontWeight: FontWeight.<em>bold</em>),<br>              children: &lt;TextSpan&gt;[<br>                TextSpan(text: <strong>&#39;open source&#39;</strong>,<br>                    style: TextStyle(<br>                        color: Colors.<em>white</em>,<br>                        fontSize: 20,<br>                        fontWeight: FontWeight.<em>bold</em>,<br>                        decoration: TextDecoration.<em>underline</em>),<br>                    recognizer: TapGestureRecognizer()<br>                      ..<strong>onTap </strong>= () {<br>                        <em>// open desired screen<br>                      </em>}<br>                ),<br>                TextSpan(<br>                    text: <strong>&#39; to &#39;</strong>,<br>                    style: TextStyle(color: Colors.<em>grey</em>,<br>                        fontSize: 20,<br>                        fontWeight: FontWeight.<em>bold</em>)<br>                ),<br>                TextSpan(<br>                    text: <strong>&#39;business,&#39;</strong>,<br>                    style: TextStyle(<br>                        color: Colors.<em>white</em>,<br>                        fontSize: 20,<br>                        fontWeight: FontWeight.<em>bold</em>,<br>                        decoration: TextDecoration.<em>underline</em>),<br>                    recognizer: TapGestureRecognizer()<br>                      ..<strong>onTap </strong>= () {<br>                        <em>// open desired screen<br>                      </em>}<br>                ),<br>                TextSpan(<br>                    text: <strong>&#39; you can host and review code, manage projects, and build software alongside 36 million developers.&#39;</strong>,<br>                    style: TextStyle(color: Colors.<em>grey</em>,<br>                        fontSize: 20,<br>                        fontWeight: FontWeight.<em>bold</em>)<br>                )<br>              ]<br>          ),<br>        )<br>    )<br>)</pre><p>And the output is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/0*A3OtZV3y-0Kp0Aj5.png" /></figure><p>We saw how RichText helps to make the text’s appearance and functionality more effective and gives the developers more options to implement the text in a certain way, whether the text is single line or a paragraph and can achieve number of such use cases in a text not limited to only login screens of various apps but can be useful in other functionalities/screens of the apps as well.</p><p>That’s all I have in this article. Thanks for reading and feel free to comment below your thoughts or any suggestions/feedback on this article. I am available on <a href="https://www.linkedin.com/in/sadia-saif/?original_referer=">LinkedIn</a>, and <a href="https://github.com/Sadia-Saif">Github.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f2b7a89865" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OOP: Object Oriented Programming]]></title>
            <link>https://medium.com/@sadiasaif.official/oop-object-oriented-programming-e88452b2a6e9?source=rss-9f8a575577cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/e88452b2a6e9</guid>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[oop]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[objectorientedprogramming]]></category>
            <dc:creator><![CDATA[Sadiasaif Official]]></dc:creator>
            <pubDate>Wed, 27 Apr 2022 02:59:07 GMT</pubDate>
            <atom:updated>2022-04-27T02:59:07.471Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pTKBsEAlJqpe5aQbAPCmFQ.png" /></figure><h3>What is Object Oriented Programming (OOP)?</h3><p>An object-oriented programming is a way programming which enables programmers to think like they are working with real-life entities<em>(a thing with distinct and independent existence)</em> or objects. In real-life, people have knowledge and can do various works. In OOP, objects have fields to store knowledge/state/data and can do various works — methods.</p><h3>Basic Terminologies:</h3><h3>Object:</h3><p>It’s the instance of a class/ it’s the working entity of a class.</p><h3>Class:</h3><p>It is a template or blue print about the capability of what an object can do.</p><h3>Method:</h3><p>The behaviours of a class. It tells what a method can do.</p><h3>Instance:</h3><p>Object and Instance both are same with small difference.</p><p><strong>A blueprint for a house design is like a class description. All the houses built from that blueprint are objects of that class. A given house is an instance.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*yp_q-EK0ox0L_aM9.png" /></figure><h3>The creation of instance is called instantiation!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/0*pgNce9LEmQs5Z3R_.png" /></figure><h3>Instance != Instance Variable:</h3><p>Instance variables belong to an instance of a class. Another way of saying that is instance variables belong to an object, since an object is an instance of a class. Every object has it’s own copy of the instance variables.</p><h3>OOPs Concepts:</h3><ol><li>Encapsulation</li><li>Abstraction</li><li>Polymorphism</li><li>Inheritance</li></ol><p><strong>NOTE: Exceptions are not part of OOPs concepts.</strong></p><h3>Encapsulation:</h3><p>Encapsulation is a mechanism of wrapping the data (instance variables) and code acting on the data (methods) together as a single unit like a Class.</p><p>The main purpose of encapsulation is you would have full control on data by using the code.</p><p>In encapsulation, the variables of a class <strong>can be made hidden</strong> from other classes, and can be accessed only through the methods of their current class. Therefore, it is also known as <strong>data hiding</strong>.</p><p><strong>Still didn’t understand?</strong></p><p>Encapsulation can be described as a <strong>protective barrier that prevents the code and data being randomly accessed by other code defined outside the class.</strong> <strong>Access to the data and code is tightly controlled by a class.</strong></p><p><strong>Data Hiding/Data Encapsulation:</strong></p><p>Encapsulation leads to data hiding.</p><p>We use access specifiers to hide the data(properties) and methods. Use of private and public comes under this.</p><p>The user can only perform a restricted set of operations on the hidden members of the class by executing special functions commonly called methods</p><h3>Abstraction:</h3><p>Abstraction is a process of hiding the implementation details from the user, only the functionality will be provided to the user.</p><p>In other words, the user will have the information on what the object does instead of how it does it.</p><p>By hiding complex steps/details/computations/statements inside your classes and creating public methods to access them. <strong>Ex: Wrapper Classes</strong></p><p>Abstraction is a very broad topic. Above can be seen as basic definition to say whenever anyone asks.</p><p>If we want to go deep, <strong>Abstraction mainly depends on point of view and many definitions.</strong></p><ul><li>Hiding unnecessary details;</li><li>Can have multiple implementations;( like dealing with idea instead of the actual event(like When you know something needs to be there but not sure how exactly it should look like.))</li><li>Building complex system by splitting the complexity level by level.</li></ul><h3>Hiding unnecessary details:</h3><p>Every function can be seen as basic abstraction.</p><p>For example: A programmer doesn’t care about how malloc() works or how garbage collection works.</p><h3>Can have multiple implementations:</h3><p>Don’t get confused this with polymorphism.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/0*9KIi4jTNU66miHtk.png" /></figure><p>Abstraction is outlined by the top left and top right images of the cat. The surgeon and the old lady designed (or visualized) the animal differently. In the same way, you would put different features in the Cat class, depending upon the need of the application.</p><blockquote><em>Every cat has a liver, bladder, heart and lung, but if you need your cat to ‘purr’ only, you will abstract your application’s cat to the design on top-left rather than the top-right.</em></blockquote><p><strong>Still didn’t get it?</strong></p><p>An abstraction is a concept that can have one or more implementations.</p><p><strong>For example</strong>: There are many different ways that your computer can connect to a local network (Ethernet, Wi-Fi, dial-up modem, etc.), but your Web browser doesn’t generally have to worry about which of these you’re using at any given time, because lower-level software provides a common abstraction that your browser can rely on. So “connection to the network” is the abstraction, and Ethernet and Wi-Fi and so on are implementations of that abstraction.</p><p>You’ll notice that so far I haven’t mentioned object-oriented programming at all. That’s because the idea of implementing abstractions is common to all sorts of designs and architectures; it’s not specific to OOP.</p><p>In object-oriented programming, where an implementation is likely to be represented as an object specified by a class, it’s common for an abstraction to be specified by an abstract class or an interface. But this does not mean that abstract classes and interfaces are only for specifying abstractions, and conversely, it doesn’t mean that all abstractions are specified by abstract classes and interfaces.</p><p>For example, the famous Design Patterns (the singleton pattern, the factory method pattern, etc.) are all abstractions that are not explicitly specified in code; rather, we have separate (unrelated) pieces of code for the various implementations of these abstractions, and the abstraction merely resides in the programmer’s head (and in design documentation, and in the names of classes and variables and so on).</p><p><strong>The abstraction is for clients (users) of the class</strong>. There needs to be an implementation, of course; but, for example, code that accepts a List&lt;String&gt; doesn’t have to worry about whether the passed-in instance is an ArrayList or a LinkedList , because they both implement the required abstraction.</p><h3>Building complex system by splitting the complexity level by level:</h3><p>Abstraction in Object Oriented Programming helps to hide the irrelevant details of an object.</p><p>Abstraction is separating the function and properties that logically can be separated to a separate entity which the main type depends on.</p><p>This kind of Abstraction helps in separating the members that change frequently.</p><p>Abstraction is one of the key principles of the OOAD(Object oriented analysis and Design).</p><p>Applying Abstraction during the design and domain modelling, helps a lot in design the a system which is flexible and maintainable.</p><blockquote><em>Abstraction can be achieved by Composition.</em></blockquote><p><strong>Abstraction Example</strong>:<br>A Car has Engine, wheels and many other parts. When we write all the properties of the Car, Engine, and wheel in a single class, it would look this way:</p><pre>public class Car <br>{ <br>    int price; <br>    String name; <br>    String color; <br>    int engineCapacity; <br>    int engineHorsePower; <br>    String wheelName; <br>    int wheelPrice;     void move()<br>    { <br>        //move forward <br>    }     void rotate()<br>    { <br>        //Wheels method <br>    }     void internalCombustion()<br>    { <br>        //Engine Method <br>    }<br>}</pre><p>In the above example, the attributes of wheel and engine are added to the Car type. As per the programming, this will not create any kind of issues. But when it comes to maintenance of the application, this becomes more complex.</p><p>Abstraction has three advantages:<br>1. By using abstraction, we can separate the things that can be grouped to another type.</p><p>2. Frequently changing properties and methods can be grouped to a separate type so that the main type need not under go changes. This adds strength to the <strong>GOAD principle -”Code should be open for Extension but closed for Modification”</strong>.</p><p>3. Simplifies the representation of the domain models.</p><p>Applying the abstraction with composition, the above example can be modified as given below:</p><pre>public class Car <br>{ <br>    Engine engine = new Engine(); <br>    Wheel wheel = new Wheel(); <br>    int price; <br>    String name; <br>    String color;     void move()<br>    { <br>        //move forward <br>    }}<br> <br>public class Engine <br>{ <br>    int engineCapacity; <br>    int engineHorsePower; </pre><pre>    void internalCombustion()<br>    { <br>        //Engine Method <br>    }<br>} public class Wheel <br>{ <br>    String wheelName; <br>    int wheelPrice; </pre><pre>    void rotate()<br>    { <br>        //Wheels method <br>    }<br>}</pre><p>You can see that the attributes and methods related to the Engine and Wheel are moved to the respective classes.<br>Engine and Wheel are referred from the Car type. When ever an instance of Car is created, both Engine and Wheel will be available for the Car and when there are changes to these Types(Engine and Wheel), changes will only be confined to these classes and will not affect the Car class.</p><p><strong>Summary</strong>:<br>Abstraction is one of the fundamental principles of Object Oriented Programming languages. It helps to reduce the complexity and also improves the maintainability of the system. When combined with the concepts of the Encapsulation and Polymorphism, Abstraction gives more power to the Object oriented programming languages.</p><h3>Abstraction is of 2 types:</h3><ol><li>Control Abstraction</li><li>Data Abstraction</li></ol><h3>Control Abstraction:</h3><p>Programming languages offer control abstraction as one of the main purposes of their use. Computer machines understand operations at the very low level such as moving some bits from one location of the memory to another location and producing the sum of two sequences of bits. Programming languages allow this to be done in the higher level. For example, consider this statement written in a <a href="https://en.wikipedia.org/wiki/Pascal_(programming_language)">Pascal</a>-like fashion:</p><pre>a := (1 + 2) * 5</pre><p>To a human, this seems a fairly simple and obvious calculation (<em>“one plus two is three, times five is fifteen”</em>). However, the low-level steps necessary to carry out this evaluation, and return the value “15”, and then assign that value to the variable “a”, are actually quite subtle and complex. The values need to be converted to binary representation (often a much more complicated task than one would think) and the calculations decomposed (by the compiler or interpreter) into assembly instructions (again, which are much less intuitive to the programmer: operations such as shifting a binary register left, or adding the binary complement of the contents of one register to another, are simply not how humans think about the abstract arithmetical operations of addition or multiplication). Finally, assigning the resulting value of “15” to the variable labeled “a”, so that “a” can be used later, involves additional ‘behind-the-scenes’ steps of looking up a variable’s label and the resultant location in physical or virtual memory, storing the binary representation of “15” to that memory location, etc.</p><p>Without control abstraction, a programmer would need to specify <em>all</em> the register/binary-level steps each time they simply wanted to add or multiply a couple of numbers and assign the result to a variable. Such duplication of effort has two serious negative consequences:</p><ol><li>It forces the programmer to constantly repeat fairly common tasks every time a similar operation is needed</li><li>It forces the programmer to program for the particular hardware and instruction set</li></ol><h3>Data Abstraction:</h3><p>Abstraction of data structures. Data abstraction refers to defining the behaviour of the data structure. Data may be internally represented in different ways in concrete implementations.</p><p>(or)</p><p>Data abstraction is the way to create complex data types and exposing only meaningful operations to interact with data type, where as hiding all the implementation details from outside works.</p><p>Benefit of this approach involves capability of improving the implementation over time e.g. solving performance issues is any. The idea is that such changes are not supposed to have any impact on client code, since they involve no difference in the abstract behaviour.</p><p><strong>EX</strong>:</p><ul><li><strong>In DBMS: </strong>Database Management Systems have abstractions of Table and View. Every DBMS software may store underlying data differently. But to users, Table is always represented as Rows and Columns. This allows performing high level operations like query on this data abstraction.</li><li><strong>In Java Collections: </strong>Collection API’s Collection, List, Set and Map interfaces are example of data abstractions. These interfaces define some of the behaviour characteristics to be implemented by concrete classes. For example, List defines characteristics and methods for random access from the underlying elements. Implementing class may choose to use <em>array</em> data structure for storing the data elements — ArrayList. Or it can be stored in any ad-hoc manner — LinkedList. Anything should be fine as long as the behaviour defined by List interface is achieved.</li></ul><h3>In short,</h3><ul><li>Abstractions are ideas, not specific events</li><li>To abstract something is to move away from its implementation (<strong> interface and abstract class</strong>) and think about big ideas</li><li>Abstractions can be used to organize code (and many other things) effectively</li><li>Object-oriented programming is entirely dependent on the abstractions.</li><li>Abstraction is the practice of breaking a large problem into smaller components, so each smaller problem can be worked on in (relative) isolation.</li></ul><h3>Next you might think about Encapsulation vs. Abstraction</h3><ul><li>The difference between concepts of encapsulation and abstraction is that encapsulation is about the packaging of the class (like how data should be accessed (setters/getters) and what data should be accessed (access specifiers)), whereas abstraction more about what the class does for you at a conceptual level.</li><li>Encapsulation is hiding unnecessary data in a capsule or unit and Abstraction is showing essential feature of an object</li><li>Abstraction encompasses encapsulation, information hiding, and generalisation.</li><li>abstraction is a form of generalisation: writing code that applies to more than one specific situation.</li><li>Abstraction is where you focus on only those details that are important for your purpose.</li><li>Abstraction is the process of refining away all the unneeded/unimportant attributes of an object and keep only the characteristics best suitable for your domain.E.g. for a person: you decide to keep first and last name and SSN. Age, height, weight etc are ignored as irrelevant.</li><li>Assembly language can be thought of as an abstraction of machine code — assembly expresses the essential details and structure of the machine code, but frees you from having to think about the opcodes used, the layout of the code in memory, making jumps go to the right address, etc.</li><li>Your operating system’s API is an abstraction of the underlying machine. Your compiler provides a layer of abstraction which shields you from the details of assembly language. The TCP/IP stack built into your operating system abstracts away the details of transmitting bits over a network. If you go down all the way to the raw silicon, the people who designed your CPU did so using circuit diagrams written in terms of “diodes” and “transistors”, which are abstractions of how electrons travel through semiconductor crystals.</li><li>Inheritance is also an example of abstraction.</li><li><strong>Encapsulation leads to Abstraction</strong></li></ul><h3>Inheritance:</h3><p>Inheritance can be defined as the process where one class acquires the properties (methods and fields) of another.</p><p>(OR)</p><p>In <a href="https://en.wikipedia.org/wiki/Object-oriented_programming">object-oriented programming</a>, <strong>inheritance</strong> is when an <a href="https://en.wikipedia.org/wiki/Object_(computer_science)">object</a> or <a href="https://en.wikipedia.org/wiki/Class_(computer_programming)">class</a> is based on another object (<a href="https://en.wikipedia.org/wiki/Prototype-based_programming">prototypal inheritance</a>) or class (<a href="https://en.wikipedia.org/wiki/Class-based_programming">class-based inheritance</a>), using the same implementation (inheriting from an object or class) specifying implementation to maintain the same behavior</p><p>The idea of inheritance implements the <strong>is a</strong> relationship. For example, mammal IS-A animal, dog IS-A mammal hence dog IS-A animal as well and so on.</p><h3>Types Of Inheritance:</h3><ol><li>Single Inheritance</li><li>Multiple Inheritance</li><li>Multi-Level Inheritance</li><li>Hierarchical Inheritance</li><li>Hybrid Inheritance</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/0*mE2JM3rI5kFGkUU6.jpeg" /></figure><p><strong>NOTE</strong>: Most of the languages like Java, JavaScript etc doesn’t support Multiple Inheritance. One of the problems we face while using it is <a href="https://en.wikipedia.org/wiki/Multiple_inheritance#The_diamond_problem">Diamond Problem</a>. Without Multiple Inheritance, Hybrid Inheritance is not possible.</p><h3>Advantages of inheritance are as follows:</h3><ul><li>Inheritance promotes reusability. When a class inherits or derives another class, it can access all the functionality of inherited class.</li><li>Reusability enhanced reliability. The base class code will be already tested and debugged.</li><li>As the existing code is reused, it leads to less development and maintenance costs.</li><li>Inheritance makes the sub classes follow a standard interface.</li><li>Inheritance helps to reduce code redundancy and supports code extensibility.</li><li>Inheritance facilitates creation of class libraries.</li></ul><h3>Disadvantages of inheritance are as follows:</h3><ul><li>Inherited functions work slower than normal function as there is indirection.</li><li>Improper use of inheritance may lead to wrong solutions.</li><li>Often, data members in the base class are left unused which may lead to memory wastage.</li><li>Inheritance increases the coupling between base class and derived class. A change in base class will affect all the child classes.</li></ul><blockquote><em>Inheritance is one of the most mis-used feature of OOPs by beginner programmers.</em></blockquote><p><strong>TIP</strong>: Unless there is an absolute need for an inheritance, don’t use it!</p><h3>Polymorphism:</h3><p>In object-oriented programming, polymorphism (from the Greek meaning “having multiple forms”) is the characteristic of being able to assign a different meaning or usage to something in different contexts — specifically, to allow an entity such as a function, or an object <strong>to have more than one form</strong>.</p><p>There are 2 types of polymorphism implementations:</p><ol><li>Static Polymorphism</li><li>Dynamic Polymorphism</li></ol><p>Features of polymorphism mainly depends on the programming languages.</p><p>Like, function overloading is possible in Java, C++ etc., but not possible in JavaScript. Operator overloading is only possible in C++.</p><p>So, I highly recommend to read about specific polymorphism depending upon the language you use.</p><h3>For basic idea what polymorphism is:</h3><p>If anybody says CUT to these people</p><ol><li>The Surgeon</li><li>The Hair Stylist</li><li>The Actor</li></ol><p>What will happen?</p><ul><li>The Surgeon would begin to make an incision.</li><li>The Hair Stylist would begin to cut someone’s hair.</li><li>The Actor would abruptly stop acting out of the current scene, awaiting directorial guidance.</li></ul><p>So above representation shows What is polymorphism (same name, different behaviour) in <strong>OOP.</strong></p><p>If you found any typo or have any suggestions, please feel free to contact me on<a href="https://github.com/Sadia-Saif"> <strong>Github</strong></a>.</p><p>Finally, if you found this helpful, please share this within your reach so that more people can benefit from this. And Follow me on<strong> </strong><a href="https://github.com/Sadia-Saif"><strong>Github</strong> </a>for getting more posts like these .😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e88452b2a6e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ternary operator in Dart]]></title>
            <link>https://medium.com/@sadiasaif.official/ternary-operator-in-dart-fbfe1358afa1?source=rss-9f8a575577cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbfe1358afa1</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[ternary-operator]]></category>
            <category><![CDATA[sadiasaif]]></category>
            <dc:creator><![CDATA[Sadiasaif Official]]></dc:creator>
            <pubDate>Wed, 27 Apr 2022 02:19:13 GMT</pubDate>
            <atom:updated>2022-04-27T02:19:13.152Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XOy1hLylM7tgA-KusYGzhA.png" /></figure><p>Ternary Conditional Operators are a pretty useful thing in Dart. They can be used to conditionally show a Flutter widget. They accept 2 operands. If the given condition is true, the first thing will be executed and if it is false, it will execute the second one.</p><h3>Example in Dart code.</h3><pre>void main() {<br>  bool isComplete = false;<br>  print(isComplete ? &quot;completed!&quot; : &quot;not Completed&quot;);<br>}<br>//Outputs not Completed</pre><p>This will print not completed. If we change the value of isComplete to true, it will print completed.</p><pre>void main() {<br>  bool isComplete = true;<br>  print(isComplete ? &quot;completed!&quot; : &quot;not Completed&quot;);<br>  //Outputs completed <br>}</pre><p>Now let’s consider a non-boolean value.</p><pre>void main() {<br>  String name = &quot;John Doe&quot;;<br>  String myName = &quot;mukhtharcm&quot;;<br>  print(name == myName ? &quot;your name is $name &quot; : &quot;your name is NOT $name &quot;);<br>}<br>//Outputs your name is NOT John Doe</pre><p>If we run this code, it’ll print your name is NOT john Doe. But if we change the value of myName to John Doe, it will print your name is John Doe</p><pre>void main() {<br>  String name = &quot;John Doe&quot;;<br>  String myName = &quot;John Doe&quot;;<br>  print(name == myName ? &quot;your name is $name &quot; : &quot;your name is NOT $name &quot;);<br>}<br>//Outputs your name is John Doe</pre><h3>Using in Flutter</h3><p>Ternary Operators are pretty handy when working with Flutter. They can be used to conditionally show widgets. Like showing a CircularProgressIndicator() when loading.</p><h4>Flutter Example</h4><pre>import &#39;package:flutter/material.dart&#39;;</pre><pre>void main() {<br>  runApp(MyApp());<br>}</pre><pre><em>class</em> MyApp <em>extends</em> StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      <em>debugShowCheckedModeBanner:</em> false,<br>      <em>home:</em> Scaffold(<br>        <em>body:</em> Center(<br>          <em>child:</em> MyWidget(),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><pre><em>class</em> MyWidget <em>extends</em> StatefulWidget {<br>  @override<br>  _MyWidgetState createState() =&gt; _MyWidgetState();<br>}</pre><pre><em>class</em> _MyWidgetState <em>extends</em> State&lt;MyWidget&gt; {<br>  bool isLoading = true;<br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      <em>body:</em> Center(<br>        <em>child:</em> Column(<br>          <em>mainAxisAlignment:</em> MainAxisAlignment.center,<br>          <em>children:</em> [<br>            isLoading ? CircularProgressIndicator() : Text(&quot;Loading Completed&quot;),<br>            SizedBox(<em>height:</em> 100),<br>            Text(&quot;Click Floating Action Button Toggle Loading&quot;)<br>          ],<br>        ),<br>      ),<br>      <em>floatingActionButton:</em> FloatingActionButton(<br>        <em>onPressed:</em> () {<br>          setState(() {<br>            isLoading = !isLoading;<br>          });<br>        },<br>      ),<br>    );<br>  }<br>}</pre><p>In the above example, isLoading is a boolean value. Initially it’s value is true. So the CircularProgressIndicator is shown. But the FloatingActionButton toggles the value of isLoading. So the CircularProgressIndicator changes to Text and vice-versa. As we saw above, we can also use values other than boolean here.</p><p>If you fancy testing this out in the browser, you can follow <a href="https://dartpad.dev/0f7f56b1ac8d25939bc53e2397edcac6">this link</a> to see a dartpad filled with sample code for this post.</p><p>If you found any typo or have any suggestions, please feel free to contact me on<a href="https://github.com/Sadia-Saif"> Github</a>.</p><p>Finally, if you found this helpful, please share this within your reach so that more people can benefit from this. And Follow me on <a href="https://github.com/Sadia-Saif">Github </a>for getting more posts like these .😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbfe1358afa1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Layout Cheat Sheet]]></title>
            <link>https://medium.com/@sadiasaif.official/flutter-layout-cheat-sheet-3e80fd3b1c8d?source=rss-9f8a575577cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e80fd3b1c8d</guid>
            <category><![CDATA[flutter-ui]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-layout]]></category>
            <category><![CDATA[flutter-widget]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <dc:creator><![CDATA[Sadiasaif Official]]></dc:creator>
            <pubDate>Tue, 26 Apr 2022 15:22:38 GMT</pubDate>
            <atom:updated>2022-04-26T15:22:38.572Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Dyhmjnz6XcPmihyyT-syew.png" /></figure><p>Do you need simple layout samples for Flutter?<br>I present you my set of Flutter layout code snippets. I will keep it short, sweet and simple with loads of visual examples.<br>Still, it is work in progress — the catalogue of samples will grow. I will focus more on the usage of Flutter widgets rather than showcasing the components (<a href="https://play.google.com/store/apps/details?id=io.flutter.demo.gallery&amp;hl=en">Flutter Gallery</a> is great for that!).<br>If you have an issue with “layouting” your Flutter or you wanna share your snippets with others, please drop a line!</p><p>This article is also available in:</p><ul><li><a href="https://www.codetime.dev.br/flutter-layout-cheat-sheet-0001/">Portuguese</a> by <a href="mailto:eddy@codetime.dev.br">Eddy</a></li></ul><p>In case you are interested in a similar article about <strong>Animations</strong>, then visit <a href="https://medium.com/flutter-community/flutter-animations-cheat-sheet-7f8cebfb850c"><strong>Flutter Animations Cheat Sheet</strong></a>.</p><h3>Table of Contents</h3><ul><li>Row and Column</li><li>IntrinsicWidth and IntrinsicHeight</li><li>Stack</li><li>Expanded</li><li>ConstrainedBox</li><li>Align</li><li>Container<br>decoration: BoxDecoration<br>• image: DecorationImage<br>• border: Border<br>• borderRadius: BorderRadius<br>• shape: BoxShape<br>• boxShadow: List&lt;BoxShadow&gt;<strong><em><br></em></strong>• gradient: RadialGradient<strong><em><br></em></strong>• backgroundBlendMode: BlendMode</li><li>Material<br>• shape: BeveledRectangleBorder</li><li>Slivers<strong><br></strong>• SliverFillRemaining</li><li>SizedBox</li><li>SafeArea</li></ul><h3>Row and Column</h3><h3>MainAxisAlignment</h3><pre>Row /*or Column*/( <br>  <strong>mainAxisAlignment</strong>: <strong>MainAxisAlignment.start</strong>,<br>  children: &lt;Widget&gt;[<br>    Icon(Icons.star, size: 50),<br>    Icon(Icons.star, size: 50),<br>    Icon(Icons.star, size: 50),<br>  ],<br>),</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e80fd3b1c8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Design Patterns in Flutter- (MVC)]]></title>
            <link>https://medium.com/@sadiasaif.official/design-patterns-in-flutter-mvc-4c865659f752?source=rss-9f8a575577cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c865659f752</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[mvc-frameworks]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Sadiasaif Official]]></dc:creator>
            <pubDate>Thu, 07 Apr 2022 07:20:36 GMT</pubDate>
            <atom:updated>2022-04-07T07:21:37.573Z</atom:updated>
            <content:encoded><![CDATA[<h3>Design Patterns in Flutter- (MVC)</h3><figure><img alt="Flutter MVC" src="https://cdn-images-1.medium.com/max/300/1*p5CFnfrX9OxMwua4Z9Drhw.png" /></figure><p><strong>Design Pattern </strong>is something which has been always a very Mysterious term for developers and we are very much confused between the term Software Architecture and Design patterns, So before starting anything about design patterns we need to clear this doubt regarding the Design Pattern and Software Architecture.</p><h3>Software Architecture</h3><blockquote><em>Software Architecture is how the whole components of system software are organized and assembled. How they communicate with each other. And the Constraint the whole UI is ruled by.</em></blockquote><p>So If we go through this definition we come across three important aspects and those are</p><ul><li>How the whole components of system software are organized and assembled:- Architectural Pattern</li><li>How they communicate with each other:- Messaging &amp; APIs</li><li>The constraints the whole UI is ruled by:- Quality Attributes</li></ul><h3>Design Pattern</h3><blockquote><em>Design Pattern could be defined as a common repeatable solution to recurring problems in software design. Design patterns can not be related to a finished design which will be directly used in code but it could be understood as a description or template for how to solve any common problem that may occur in many situations.</em></blockquote><p>So If we go through this Definition we will find that</p><ul><li>It is a solution to recurring problems of software development.</li><li>It is not a sample code which will be directly used in the project.</li><li>It is just a template that helps to solve any problem that occurs in software development.</li></ul><h3>Difference between Software Architecture and Design Pattern</h3><p>So after going through both the definition we came to know that both of it could be differentiated on the basis</p><p><strong>Scope:-</strong> Software Architecture has a <strong>universal scope</strong>, it has to managed at a <strong>Higher level </strong>like<strong> </strong>Server Configuration, etc.Whereas Design pattern has a <strong>Lowe level</strong> scope that comes to the project internal code pattern.</p><p><strong>Working:- </strong>Software Architecture is all about organizing and assembling the components in such a way that their communication is very much convenient and secure. Whereas a Design pattern is about how the components are built.</p><p>So I hope this comparison clears the doubt between Software Architecture and Design Pattern. So after having a piece of knowledge that what design pattern actually we will start a few famous design patterns which are mainly used in flutter development. So, First of all, we will start with the very Basic MVC Pattern and we will see how MVC is used in Flutter.</p><h3>MVC In Flutter</h3><p>MVC stands for the model view controller and its main work is to have a segregated code base, it aims to separate the code and area of responsibility while software development. The main focus of MVC is to separate the interface of the project from the functionality and the data that is used in the application. As we all know that neat and arranged things are always easy to use and maintain, the same is with MVC it makes the codebase neat and arranged and it achieves these with three of its components.</p><ul><li><strong>Model:- </strong>Model compromises of the data source it may be from anywhere DB, API, JSON, etc. In some cases, it may consist of some business logic.</li><li><strong>View:- </strong>View is all about the user interface, I.e displaying data and taking inputs from the user.</li><li><strong>Controller:- </strong>It contains the business logic, I.e Controlling what data will be shown to the user, user input handling, etc.</li></ul><h3>Communication Flow</h3><p>Differentiating the three of these basic components of projects helps the developer to write a neat and modular code which makes the code Reusable and also helps in parallel development. It becomes very easy to work on the project as it does not affect other parts of the project if something is changed in one part. So keeping them separated needs a communication flow in which they will interact with each other and achieve the functioning of the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yCTuGfAB63C1KNst.png" /></figure><p>So as we could see from the following flow diagram the User interacts with the View part of the project which helps the user to see the Data and provide the input to the controller through the view. Controller Active as the brain of the project does the calculation or manipulation of data from the user or takes the data from the model to work on it and provides it to the View which shows the desired data to the user. Here we find that the View shows and receives the data but it directly not interact with the Model, it is the controller that plays a role between view and model in data manipulation and data representation. The View and the Model are tightly coupled to the Controller i.e View Knows how to communicate to Controller, Controller knows how to communicate to Model and Model and View works collectively without knowing each other existence.</p><h3>Code Understanding:</h3><p>If you have not installed the flutter SDK or you are still getting familiar with it :</p><p>Let’s dive into the code part for an In-depth understanding of the process:-</p><blockquote><strong><em>1.</em></strong><em> </em><strong><em>Firstly</em></strong><em>, Create a new project and then clear all the code in the main.dart file. Type below command in your terminal:-</em></blockquote><pre>flutter create <strong><em>yourProjectName</em></strong></pre><ul><li>Add the current latest version of <strong>MVC pattern</strong> package under the dependencies in <strong>pubspec.yaml</strong> file.</li></ul><pre>dependencies:   <br><strong> mvc_pattern: ^3.4.1</strong></pre><h3>Create a Model Class:</h3><p>As Explained above a model class is created for both counter:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/0*saXByhBJfapUI3iW.png" /></figure><h3>Create the Main Controller :</h3><p>The Controller is Created as this Basically Ensures the interaction with the model :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/0*Kj-YLLiZntt_QyGK.png" /></figure><h3>Adapting it Into The View :</h3><p>The controller is then bound to the view.dart file so that the increment and decrement functionality may work as depicted.</p><h3><a href="https://github.com/flutter-devs/Flutter_MVC">A new Flutter application. This project is a starting point for a Flutter application. A few resources to get you…</a></h3><p><a href="https://github.com/Sadia-Saif">Sadia-Saif - Overview</a></p><p>Closing Thoughts</p><p>Design Pattern is a<strong> Quintessential</strong> tool in large scale apps in native applications which you can also practice in flutter also. In this Blog, only MVC has been explained but this will a series of blogs and in the next blogs, we will be sharing about MVP, MVVM, CLEAN, etc.</p><p>If you have not used Design Patterns in Flutter, I hope this article has provided you with valuable information about what is all about it, and that you will give it Design Patterns — a Try. Begin using them for your Flutter Apps !!</p><p>Feel free to connect with us:</p><p>We<a href="https://flutter.io/support/"> <strong>welcome feedback</strong></a> and hope that you share what you’re working on using #<strong>Flutter</strong>. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences!</p><p>Thank you for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c865659f752" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>