<?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 Ishan Fernando on Medium]]></title>
        <description><![CDATA[Stories by Ishan Fernando on Medium]]></description>
        <link>https://medium.com/@ishanfx?source=rss-c6ddf75bc9ea------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TUiZlh3upqoEpUfdAT6Bkg.png</url>
            <title>Stories by Ishan Fernando on Medium</title>
            <link>https://medium.com/@ishanfx?source=rss-c6ddf75bc9ea------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 18:06:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ishanfx/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[Angular Material dialog complete guide]]></title>
            <link>https://ishanfx.medium.com/angular-material-dialog-complete-guide-383741b99dcc?source=rss-c6ddf75bc9ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/383741b99dcc</guid>
            <category><![CDATA[angular-material]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Ishan Fernando]]></dc:creator>
            <pubDate>Fri, 19 Aug 2022 18:51:06 GMT</pubDate>
            <atom:updated>2022-10-30T16:01:53.754Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kpeTj___cioskaPHHQDhxw.png" /></figure><p>In this article explain I am going a explain how to create a dialog in Angular project. For this tutorial, I am gone use one of the most famous <strong>Material UI</strong> Angular library. It contains a feature-packed dialog component which we can use for any project.</p><p>This article contains following section</p><ol><li>How to install the plugin and create a simple dialog</li><li>How to disable dialog close when clicking outside</li><li>Material dialog useful configuration options</li><li>How to pass data to the material dialog</li><li>How to pass data when closing the dialog</li></ol><h3>How to install the plugin and create a simple dialog</h3><p>Before creating a modal first you must install the required packages using the following command.</p><pre>ng add @angular/material</pre><p>This will install Angular Material, the <a href="https://material.angular.io/cdk/categories">Component Dev Kit (CDK)</a> and <a href="https://angular.io/guide/animations">Angular Animations</a>. Also, it will ask for the theme, global typography and setup browser animation. Make sure to select yes for browser animation. Otherwise, most of the animation in the Material module will not work.</p><p>Next, you can add the required material module to the angular module file. In this tutorial, I am using a fresh project and the only module which I have is the app module. You can add this to any module which you are hoping to use the dialog</p><pre>import { MatDialogModule } from &#39;@angular/material/dialog&#39; @NgModule({ imports: [ .... MatDialogModule, ] })</pre><p>Let&#39;s create a component to use as a dialog. Execute the following command and it will create a detail-dialog component under the component folder.</p><pre>ng g c component/detail-dialog</pre><p>Open the Html file of the created component and add the following HTML part.</p><pre>&lt;h1 mat-dialog-title&gt;User Details&lt;/h1&gt; &lt;div mat-dialog-content&gt; &lt;p&gt;Name : Shan&lt;/p&gt; &lt;/div&gt; &lt;div mat-dialog-actions&gt; &lt;button mat-button mat-dialog-close&gt;Close&lt;/button&gt; &lt;/div&gt;</pre><p>In here you can see mainly 3 attributes.</p><ol><li><strong>mat-dialog-title</strong> - This is used to define the title of the dialog.</li><li><strong>mat-dialog-content</strong> - Inside this div you can specify the content of the dialog</li><li><strong>mat-dialog-actions</strong> - In here you can specify the list of action buttons. This will show at the bottom of the dialog.</li></ol><p>Now you need a way to show the dialog when someone triggers an action. Therefore let&#39;s add a button to the main <strong>AppComponent</strong>.</p><pre>&lt;button (click)=&quot;showDialog()&quot;&gt;Show Contact Dialog&lt;/button&gt;</pre><p>Inside the <strong>app.component.ts</strong> file you need to add the trigger event.</p><p>Here,first, we need to inject the <strong>MatDialog</strong> service from the constructor. <strong>MatDialog</strong> service contains the <strong>open</strong> method which accepts dialog component as a first parameter.</p><pre>import { MatDialog } from &#39;@angular/material/dialog&#39;; import { DetailDialogComponent } from &#39;./component/detail-dialog/detail-dialog.component&#39;; export class AppComponent { title = &#39;dialog-app&#39;; constructor(private matDialog:MatDialog){ } showDialog(){ this.matDialog.open(DetailDialogComponent) } }</pre><p>When you click the button now you will be able to see a simple dialog.</p><h3>How to disable dialog close when clicking outside</h3><p>Default when user clicks outside of the dialog it gets closed. This behaviour can be changed by setting <strong>disableClose</strong> to true in the <strong>MatDialogConfig</strong>.</p><p>First, create an object of <strong>MatDialogConfig</strong> class and set <strong>disableClose</strong> property to true.</p><pre>showDialog(){ const mdConfig = new MatDialogConfig(); mdConfig.disableClose = true; this.matDialog.open(DetailDialogComponent,mdConfig) }</pre><p>Also you can just set those configurations like below.</p><pre>this.matDialog.open(DetailDialogComponent,{width:&quot;500px&quot;,direction: &quot;rtl&quot;})</pre><p>Other than that you can change the following property by changing the dialog config.</p><h3>Material dialog useful configurations options</h3><h4>Disable backdrop</h4><pre>mdConfig.hasBackdrop = false;</pre><h4>Set dialog width</h4><pre>mdConfig.width = &quot;500px&quot;</pre><h4>Set the dialog position</h4><pre>mdConfig.position = {top:&quot;0px&quot;}</pre><p>This will show the dialog in the top of the page. Default it shows in the center. You can also specify the <strong>left</strong>, <strong>right</strong>, and <strong>bottom</strong> values.</p><h4>Set the direction</h4><p>Default content will be shown from <strong>left to right</strong>. If you need to change that from right to left you can change this property.</p><pre>mdConfig.direction = &quot;rtl&quot;</pre><h3>How to pass data to the material dialog</h3><p>When creating a dialog usually needs a way to pass details to the dialog. Let&#39;s say we are creating a dialog to edit user details. When the user clicks the edit we need to pass those details to the dialog.</p><p>To pass data we can use the <strong>data</strong> property in <strong>MatDialogConfig</strong> object.</p><pre>mdConfig.data = { name:&#39;Shan&#39;, &lt;email:&quot;shan@gmail.com&gt;&quot; } this.matDialog.open(DetailDialogComponent,mdConfig)</pre><p>Or we can directly specify the data like below</p><pre>this.matDialog.open(DetailDialogComponent,{data: { name:&#39;Shan&#39;, &lt;email:&quot;shan@gmail.com&gt;&quot; }})</pre><p>Next we should access those values inside the dialog component. To that, we need to use <strong>MAT_DIALOG_DATA</strong> injectable. It will give access to the data which is passed previously. Then you can set those values to the userDetails object.</p><pre>export class DetailDialogComponent implements OnInit {<br>  public userDetails: {<br>    name ? :string,<br>    email ? :string<br>  } = {};<br>  constructor(<a href="http://twitter.com/Inject">@Inject</a>(MAT_DIALOG_DATA) public data: any) {<br>    this.userDetails = data<br>  }<br>}</pre><p>Then you can access those values in the template</p><pre>&lt;h1 mat-dialog-title&gt;User Details&lt;/h1&gt; &lt;div mat-dialog-content&gt; &lt;p&gt;Name : {{userDetails.name}}&lt;/p&gt; &lt;p&gt;Email : {{userDetails.email}}&lt;/p&gt; &lt;/div&gt; &lt;div mat-dialog-actions&gt; &lt;!-- &lt;button mat-button mat-dialog-close&gt;Close&lt;/button&gt; --&gt; &lt;button mat-button (click)=&quot;closeDialog()&quot;&gt;Close&lt;/button&gt; &lt;/div&gt;</pre><h3>How to pass data when closing the dialog</h3><p>Often we need to pass some values to the main component when the user closes the dialog. This can be easily done through the <strong>close</strong> method.</p><p>First, inject <strong>MatDialogRef</strong> service through the <strong>constructor</strong>.</p><p>Here you can add a custom <strong>closeDialog</strong> function to trigger when the user clicks the close button on the dialog.</p><p>we can pass data object or value to the close method like below</p><pre>constructor(<a href="http://twitter.com/Inject">@Inject</a>(MAT_DIALOG_DATA) public data: any, private dialogRef: MatDialogRef &lt; DetailDialogComponent &gt; ) {<br>  this.userDetails = data<br>}<br>closeDialog() {<br>  this.dialogRef.close({<br>    action: &#39;Yes&#39;<br>  });<br>}</pre><p>In the app <strong>component</strong> we need to create a variable to keep dialog reference. We can subscribe to the <strong>afterClosed</strong> observable to get the data.</p><pre>showDialog() {</pre><pre>const dialogRef = this.matDialog.open(DetailDialogComponent, {<br>    data: {<br>      name: &#39;Shan&#39;,<br>      &lt;email: &quot;<a href="/service/mailto:shan@gmail.com">shan@gmail.com</a>&gt;&quot;<br>    }<br>  })</pre><pre>dialogRef.afterClosed().subscribe(result = &gt;{<br>    console.log(`Dialog result: $ {<br>      JSON.stringify(result)<br>    }`);<br>  });<br>}</pre><h3>Conclusion</h3><p>This article discussed how to install and use material dialog in your angular application. Also, we discussed how to pass data to dialog and pass data to the main component when the user closes the dialog. Other than that we also discussed a few configurations which we can do to customize material dialog</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=383741b99dcc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3 ways to Clone Array in Javascript]]></title>
            <link>https://ishanfx.medium.com/3-ways-to-clone-array-in-javascript-792ca8ca71d2?source=rss-c6ddf75bc9ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/792ca8ca71d2</guid>
            <category><![CDATA[js]]></category>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[array-clone]]></category>
            <category><![CDATA[copy-json-array]]></category>
            <dc:creator><![CDATA[Ishan Fernando]]></dc:creator>
            <pubDate>Fri, 20 Nov 2020 02:53:43 GMT</pubDate>
            <atom:updated>2020-11-20T02:53:43.127Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u3RNjSrUf13Vg-Akt0PV4g.png" /></figure><p>As a programmer, we often need a way to copy the existing array elements to a new array. But there is some issue which can arise if you did not do it properly.</p><h3>Can we assign one array to another array to copy?</h3><p>In javascript, arrays consider as a reference type. That means if we assign one array to another array it does not assign the values to a new array. It only assigns the reference to the original array. Therefore if we change the element in the second array, the element in the first array also get affected.</p><p>In below example you can see even though we have added ‘Mango’ to newFruits array, both fruits and newFruits array get changed.</p><pre>var fruits = [&#39;Apple&#39;,&#39;Orange&#39;];<br><br>var newFruites = fruits;<br><br>newFruites.push(&#39;Mango&#39;)<br><br>console.log(fruits);<br>//[ &#39;Apple&#39;, &#39;Orange&#39;, &#39;Mango&#39; ]<br><br>console.log(newFruites);<br>//[ &#39;Apple&#39;, &#39;Orange&#39;, &#39;Mango&#39; ]</pre><h3>Shallow copy vs deep copy</h3><p>Before starting to learn the method of copying, we have to clarify the two-term shallow copy and the deep copy. Shallow copy only copies the first level element. That’s mean it doesn’t work for the multi-dimension array. Those are pass as a reference. But deep copy will copy the first level as well as a nested element to the new array.</p><h3>Spread operator</h3><p>ES6 way of copying array is using the spread operator. This is a shallow copy and does not work with the multi-dimension array.</p><pre>var fruits = [&#39;Apple&#39;,&#39;Orange&#39;];<br><br>var newFruites = [...fruits];<br><br>console.log(newFruites);<br>//[ &#39;Apple&#39;, &#39;Orange&#39; ]<br>newFruites.push(&#39;Mango&#39;)<br><br>console.log(fruits);<br>//[ &#39;Apple&#39;, &#39;Orange&#39; ]<br><br>console.log(newFruites);<br>//[ &#39;Apple&#39;, &#39;Orange&#39;, &#39;Mango&#39; ]</pre><h3>Slice method</h3><p>Array Slice method also allows copying the array element. This one also a method of shallow copying. This is the old way of copying the array before the spread operator introduced.</p><pre>var fruits = [&#39;Apple&#39;,&#39;Orange&#39;];<br><br>var newFruites = fruits.slice();<br><br>console.log(newFruites);<br>//[ &#39;Apple&#39;, &#39;Orange&#39; ]<br>newFruites.push(&#39;Mango&#39;)<br><br>console.log(fruits);<br>//[ &#39;Apple&#39;, &#39;Orange&#39; ]<br><br>console.log(newFruites);<br>//[ &#39;Apple&#39;, &#39;Orange&#39;, &#39;Mango&#39; ]</pre><h3>Array from method</h3><p>Array.from() static method also can use to create a copy of an array. This one also a method of shallow coping.</p><pre>var fruits = [&#39;Apple&#39;,&#39;Orange&#39;];<br><br>var newFruites = Array.from(fruits);<br><br>newFruites.push(&#39;Mango&#39;)<br><br>console.log(fruits);<br>//[ &#39;Apple&#39;, &#39;Orange&#39;, &#39;Mango&#39; ]<br><br>console.log(newFruites);<br>//[ &#39;Apple&#39;, &#39;Orange&#39;, &#39;Mango&#39; ]</pre><h3>Can we do Deep Copy for an Array of objects/Multi dimension array?</h3><p>If you have an array of object or multi-dimension array these methods will not be work. In that case, you have to do a deep copy.</p><p>You can use JSON.stringify() and JSON.parse() method to copy Object array/multi-dimension array to a new one. On here, the stringify method converts the object to string and you can convert that string to JSON/Array again by using JSON.parse() method.</p><pre>var fruits = [<br>	{<br>	 name:&#39;Apple&#39;,<br>	 color:&#39;Red&#39;,<br>	},<br>	{<br>	 name:&#39;Mango&#39;,<br>	 color:&#39;Green&#39;,<br>	}<br>];<br><br>//var newFruites = fruits.slice();<br>var newFruites = JSON.parse(JSON.stringify(fruits));<br><br>newFruites[0][&#39;color&#39;] = &#39;Green&#39;;<br><br>console.log(fruits);<br>//[{ name: &#39;Apple&#39;, color: &#39;Red&#39; }, <br>   { name: &#39;Mango&#39;, color: &#39;Green&#39; } ]<br><br>console.log(newFruites);<br>//[{ name: &#39;Apple&#39;, color: &#39;Green&#39; },<br>    { name: &#39;Mango&#39;, color: &#39;Green&#39; }]</pre><p>Hope you got a better idea about a different way of coping array in Javascript and now you can decide which method is suitable for you. When using spread operator you have to be careful about the browser compatibility. Because it does not support IE.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=792ca8ca71d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create Hyperlink for Text in Flutter]]></title>
            <link>https://medium.com/shipkaro/how-to-create-hyperlink-for-text-in-flutter-ecf7d6019dfb?source=rss-c6ddf75bc9ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecf7d6019dfb</guid>
            <category><![CDATA[mobile-development]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[flutter-hyperlink]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-vs-react]]></category>
            <dc:creator><![CDATA[Ishan Fernando]]></dc:creator>
            <pubDate>Fri, 23 Oct 2020 00:00:00 GMT</pubDate>
            <atom:updated>2020-11-15T16:03:18.357Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jxGyC-Wqqrlo8XiDwMISEw.png" /></figure><p>In most of the mobile application, there are links which redirect the users to some external website for further read about particular section or an article. Therefore we will need a way to accomplish this in our Flutter app.</p><p>There is no build-in widget to add a link to text in Flutter. But there are some work-round which we can use to accomplish the same goal.</p><h3>Add the plugin</h3><p>First, you need a url_launcher plugin if we need to redirect the user to the external website. Load the pubspec.yaml and apply that plugin</p><pre>url_launcher: ^5.7.5</pre><p>Run the following command to get the plugin or your project</p><pre>flutter pub get</pre><p>Next import the plugin where you want to use that.</p><pre>import &#39;package:url_launcher/url_launcher.dart&#39;;</pre><h3>Load URL when pressing the text</h3><p>Usually when we add ing a link like “read more” we will add it as a part of an existing paragraph. For that, we have to use the RichText widget which allows using TextSpan widget to separate some wording to add the unique style.</p><p>For one TextSpan you can make the text style looks like the link by adding the blue colour and you can use recogniser property to set a Gesture detector for a particular text. It will help to capture the text click in the widget. In there you can use the launch method to load the particular URL when someone Tap on the text.</p><pre>RichText(<br>          text: TextSpan(<br>            children: [<br>              TextSpan(<br>                style: defaultText,<br>                text: &quot;To learn more &quot;<br>              ),<br>              TextSpan(<br>                style: linkText,<br>                 text: &quot;Click here&quot;,<br>                  recognizer: TapGestureRecognizer()..onTap =  () async{<br>                    var url = &quot;https://www.youtube.com/channel/UCwxiHP2Ryd-aR0SWKjYguxw?view_as=subscriber&quot;;<br>                        if (await canLaunch(url)) {<br>                          await launch(url);<br>                        } else {<br>                          throw &#39;Could not launch $url&#39;;<br>                        }<br>                  }<br>              ),<br>            ]<br>        ))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*98ae4tFK4dW7-NnT.png" /></figure><h3>Turn Text URL to Clickable link using linkify</h3><p><a href="https://pub.dev/packages/flutter_linkify">linkify</a> Flutter plugin can turn text URL and email to a clickable inline text.</p><p>First, add flutter_linkify plugin to your project.</p><pre>dependencies:<br>         flutter_linkify: ^3.1.3</pre><p>Next import to the file which you are going to implement the code.</p><pre>import &#39;package:flutter_linkify/flutter_linkify.dart&#39;;</pre><p>Now you can directly use the widget like below</p><pre>Linkify(<br>            onOpen: (link)  {<br>                  print(&quot;Linkify link = ${link.url}&quot;);<br>                },<br>            text: &quot;Linkify click -  https://www.youtube.com/channel/UCwxiHP2Ryd-aR0SWKjYguxw&quot;,<br>            style: TextStyle(color: Colors.blue),<br>            linkStyle: TextStyle(color: Colors.green),<br>            ),</pre><p>onOpen callback will pass the link and you can perform any action from there. In this case, I only print the link in the console, but you can use the launch method to launch the actual URL in a browser.</p><h4>How to show http:// or https:// in the link text</h4><p>You can enable humanize option to true to make this happen.</p><pre>options: LinkifyOptions(humanize: false),</pre><h4>Remove www from the link</h4><pre>options: LinkifyOptions(removeWww: true)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*ELgOzAxEEEXu4oIj.png" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FurnrIW-eaX4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DurnrIW-eaX4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FurnrIW-eaX4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d46f5822ca999249f4c010f9129c60c6/href">https://medium.com/media/d46f5822ca999249f4c010f9129c60c6/href</a></iframe><p><em>Originally published at </em><a href="https://mightytechno.com/create-hyperlink-for-text-in-flutter/"><em>https://mightytechno.com</em></a><em> on October 23, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecf7d6019dfb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/shipkaro/how-to-create-hyperlink-for-text-in-flutter-ecf7d6019dfb">How to create Hyperlink for Text in Flutter</a> was originally published in <a href="https://medium.com/shipkaro">shipkaro — my journey to $10k</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Flip Card Animation With 3D Effect]]></title>
            <link>https://medium.com/shipkaro/flutter-flip-card-animation-with-3d-effect-4284af04f5a?source=rss-c6ddf75bc9ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/4284af04f5a</guid>
            <category><![CDATA[flutter-card-flip]]></category>
            <category><![CDATA[flutter-widget]]></category>
            <category><![CDATA[flutter-animation]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Ishan Fernando]]></dc:creator>
            <pubDate>Sat, 29 Feb 2020 20:37:57 GMT</pubDate>
            <atom:updated>2021-07-28T01:56:15.277Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nn8_J8DcmASOFHcck__ZcA.jpeg" /></figure><p>Implementing Card Flip Animation In Flutter will not be hard as you think because of the Widgets and Classes provided by Flutter.</p><p>I will teach you how to implement Flip card animation to your next flutter project from scratch. At the end of the article, you will have beautiful 3D Flip card <a href="https://mightytechno-283fdd.easywp.com/flutter-button-animation/">animation</a> with a few lines of code</p><h3>Start with basic Container</h3><p>To get started first you will need some kind of Container and we will use this as our main component when Animation occur. This is a basic container with the Icon in the Middle.</p><pre>    Container(<br>                      color: Colors.blueAccent,<br>                      width: 200,<br>                      height: 200,<br>                      child: Icon(<br>                        Icons.ac_unit,<br>                        color: Colors.white,<br>                        size: 50,<br>                      ),<br>                    )</pre><h3>Implement Animation to Flip Card</h3><p>When implementing an animation there are two things which we need, <a href="https://mightytechno-283fdd.easywp.com/flutter-button-animation/">Animation</a> class and <a href="https://mightytechno-283fdd.easywp.com/flutter-button-animation/">AnimationController</a> class. Animation class will do the actual Animation part and the AnimationController class will help to control the animation like whether we need to do forward or backwards or more.</p><p>Of course, we need to use a stateful widget for this implementation.</p><p>First Create a new object of <a href="https://api.flutter.dev/flutter/animation/AnimationController-class.html">AnimationController</a> and Animation class. Also, we need to track the animation status to do flip in forward and backwards. For that, you can use AnimationStatus enum.</p><pre>AnimationController _animationController;<br>  Animation _animation;<br>    AnimationStatus _animationStatus = AnimationStatus.dismissed;<br><br>    @override<br>      void initState() {<br>        super.initState();<br>        _animationController =<br>            AnimationController(vsync: this, duration: Duration(seconds: 1));<br>        _animation = Tween(end: 1, begin: 0).animate(_animationController)<br>          ..addListener(() {<br>            setState(() {});<br>          })<br>          ..addStatusListener((status) {<br>            _animationStatus = status;<br>          });<br>      }</pre><p>For the animationController we have to provide vsync and it accept TickerProvider. That can be provided by SingleTickerProviderStateMixin. Because of that, we use SingleTickerProviderStateMixin mixin by using with keyword like below.</p><pre>class _FlipCardState extends State<br>    with SingleTickerProviderStateMixin {</pre><p>Duration property will define the duration of the animation between the start and stop. For this we use <a href="https://flutter.dev/docs/development/ui/animations">Tween Animation</a> with begin value 0 and end as 1. addStatusListener method will set the status of the animation whether is dismissed, forward, reverse or completed. Dismissed mean the animation is stop in the beginning and that will be the initial value.</p><h3>Make container Clickable</h3><p>You can Wrap the container inside the <a href="https://api.flutter.dev/flutter/widgets/GestureDetector-class.html">GestureDetector</a> widget to make it clickable. GestureDetector onTap will trigger when you tap the container and that where we need to start our animation. In there if the Animation is dismissed mean stop in start state, you can animate a container in forward. Which mean the Tween animation value will be changed in a forward manner.</p><pre>     GestureDetector(<br>              onTap: () {<br>                if (_animationStatus == AnimationStatus.dismissed) {<br>                  _animationController.forward();<br>                } else {<br>                  _animationController.reverse();<br>                }<br>              },<br>              child:  Container(<br>                      color: Colors.blueAccent,<br>                      width: 200,<br>                      height: 200,<br>                      child: Icon(<br>                        Icons.ac_unit,<br>                        color: Colors.white,<br>                        size: 50,<br>                      ),<br>                    )<br>                  ,<br>            )</pre><p>Things not finished yet,</p><h3>Add Transform with 3d Effect</h3><p>The next thing you need to do is wrap the GestureDetector inside the <a href="https://api.flutter.dev/flutter/widgets/Transform-class.html">Transform</a> widget. Transform widget can use to add a different transform to child widget.</p><p>For the Flip animation, you need to rotate in x-axis from the middle. So we set alignment to centre and set some Matrix to transform property. You can just set 2D transform by setting only the rotateX. but if you need 3D kind of effect you have to setEntry method. You can change these values and play around to get a different effect and I think these values fit best for my case. I am not a math person and if you are you will have a better sense of these values.</p><p><strong>Under the hood when the animation get started the value of animation which you can access from _animation.value get change from 0 to 1. So we are setting that value by multiplying with PI. PI is equal to 180 and from the start to the end we change that value from 0 to 180 and that exactly why it rotates 180 degrees.</strong></p><pre>Transform(<br>            alignment: FractionalOffset.center,<br>            transform: Matrix4.identity()<br>              ..setEntry(3, 2, 0.002)<br>              ..rotateX(pi * _animation.value),<br>            child: GestureDetector(<br>              onTap: () {<br>                if (_animationStatus == AnimationStatus.dismissed) {<br>                  _animationController.forward();<br>                } else {<br>                  _animationController.reverse();<br>                }<br>              },<br>              child:  Container(<br>                      color: Colors.blueAccent,<br>                      width: 200,<br>                      height: 200,<br>                      child: Icon(<br>                        Icons.ac_unit,<br>                        color: Colors.white,<br>                        size: 50,<br>                      ),<br>                    )<br>                  ,<br>            ),<br>          )</pre><p>Now the all animation and Flip card things are working as expected. But how can we change the card when it flips.</p><h3>Add different card to front and Back</h3><p>You can do a small trick to make it work. When Animation is in progress we know it changes values from 0 to 1. When this value comes to 0.5, the card which will be in a 90-degree angle. In that position, we can swipe the container. So if the animation value is less than 0.5 we use blue container and if not we use the red container. pretty easy right.</p><pre>_animation.value &lt;= 0.5<br>                  ? Container(<br>                      color: Colors.blueAccent,<br>                      width: 200,<br>                      height: 200,<br>                      child: Icon(<br>                        Icons.ac_unit,<br>                        color: Colors.white,<br>                        size: 50,<br>                      ),<br>                    )<br>                  : Container(<br>                      color: Colors.red,<br>                      width: 200,<br>                      height: 200,<br>                      child: Icon(<br>                        Icons.ac_unit,<br>                        color: Colors.white,<br>                        size: 50,<br>                      ),<br>                    ),</pre><p>Now this is the Full Code.</p><pre>class _FlipCardState extends State<br>    with SingleTickerProviderStateMixin {<br>          AnimationController _animationController;<br>          Animation _animation;<br>          AnimationStatus _animationStatus = AnimationStatus.dismissed;<br><br>          @override<br>          void initState() {<br>            super.initState();<br>            _animationController =<br>                AnimationController(vsync: this, duration: Duration(seconds: 1));<br>            _animation = Tween(end: 1, begin: 0).animate(_animationController)<br>              ..addListener(() {<br>                setState(() {});<br>              })<br>              ..addStatusListener((status) {<br>                _animationStatus = status;<br>              });<br>          }<br><br>      @override<br>      Widget build(BuildContext context) {<br>        return Scaffold(<br>          appBar: AppBar(<br>            // Here we take the value from the MyHomePage object that was created by<br>            // the App.build method, and use it to set our appbar title.<br>            title: Text(widget.title),<br>          ),<br>          body: Container(<br>            color: Color.fromARGB(255, 27, 28, 30),<br>            child: Center(<br>              child: Transform(<br>                alignment: FractionalOffset.center,<br>                transform: Matrix4.identity()<br>                  ..setEntry(3, 2, 0.002)<br>                  ..rotateX(pi * _animation.value),<br>                child: GestureDetector(<br>                  onTap: () {<br>                    if (_animationStatus == AnimationStatus.dismissed) {<br>                      _animationController.forward();<br>                    } else {<br>                      _animationController.reverse();<br>                    }<br>                  },<br>                  child: _animation.value &lt;= 0.5<br>                      ? Container(<br>                          color: Colors.blueAccent,<br>                          width: 200,<br>                          height: 200,<br>                          child: Icon(<br>                            Icons.ac_unit,<br>                            color: Colors.white,<br>                            size: 50,<br>                          ),<br>                        )<br>                      : Container(<br>                          color: Colors.red,<br>                          width: 200,<br>                          height: 200,<br>                          child: Icon(<br>                            Icons.ac_unit,<br>                            color: Colors.white,<br>                            size: 50,<br>                          ),<br>                        ),<br>                ),<br>              ),<br>            ),<br>          ),<br>    );<br>  }<br>}</pre><h4>Conclusion</h4><p>I hope you get an idea about how to implement Flip card animation in flutter and If you have any questions please add a comment below.</p><p><strong>Check the Full Video Here — </strong><a href="https://youtu.be/36qFMp_uvF0"><strong>https://youtu.be/36qFMp_uvF0</strong></a></p><p>Originally published at <a href="https://mightytechno.com/gradient-in-flutter/">mightytechno</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4284af04f5a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/shipkaro/flutter-flip-card-animation-with-3d-effect-4284af04f5a">Flutter Flip Card Animation With 3D Effect</a> was originally published in <a href="https://medium.com/shipkaro">shipkaro — my journey to $10k</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Navigation Drawer from Basic to Custom Drawer]]></title>
            <link>https://medium.com/shipkaro/flutter-navigation-drawer-from-basic-to-custom-drawer-66a60d27d687?source=rss-c6ddf75bc9ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/66a60d27d687</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[drawer-sticky-header]]></category>
            <category><![CDATA[custom-drawer-navigation]]></category>
            <category><![CDATA[flutter-widget]]></category>
            <category><![CDATA[flutter-navigation-drawer]]></category>
            <dc:creator><![CDATA[Ishan Fernando]]></dc:creator>
            <pubDate>Sun, 24 Nov 2019 18:46:01 GMT</pubDate>
            <atom:updated>2021-07-28T01:59:33.890Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*itZH6xNS7ai-OGkuQAuYEQ.png" /></figure><p>When comes to the navigation in-app, <a href="https://material.io/components/navigation-drawer/">Navigation drawer</a> can be considered of the one primary method of Navigation</p><p>In <a href="https://flutter.dev/docs/cookbook/design/drawer">Flutter, Navigation Drawer</a> comes with the Scaffold widget. Therefore before adding a navigation drawer we need to define a <a href="https://api.flutter.dev/flutter/material/Scaffold-class.html">Scaffold</a>.</p><p>When we creating a sample flutter app, it comes with the default scaffold. There is a option to set a drawer like below</p><pre>Scaffold(<br>        drawer: <br>       )</pre><h3>Create a basic navigation drawer</h3><p>Now we already have a skeleton with the <a href="https://api.flutter.dev/flutter/material/Scaffold-class.html">Scaffold widget</a>. For that we need to set <a href="https://api.flutter.dev/flutter/material/Drawer-class.html">Drawer widget</a>.</p><p>To properly structuring the Drawer you need to set Header part and the below you can add some menu items. For that, you have to create a <a href="https://api.flutter.dev/flutter/widgets/ListView-class.html">Listview</a> and add the first child as a <a href="https://api.flutter.dev/flutter/material/DrawerHeader-class.html">DrawerHeader</a> and after that, you can add <a href="https://api.flutter.dev/flutter/material/ListTile-class.html">ListTile</a> widget to show other menu items.</p><pre>drawer: Drawer(<br>      child: ListView(<br>        padding: EdgeInsets.zero,<br>        children: [<br>              DrawerHeader(<br>                   child: Text(&quot;Header&quot;),<br>                 ),<br>              ListTile(<br>                  title: Text(&quot;Home&quot;),<br>                )<br>        ],<br>      ),<br>  ),</pre><h3>Navigation Drawer header image</h3><p>Before adding an image you have to make an <a href="https://flutter.dev/docs/development/ui/assets-and-images">assets folder and create an images folder inside that</a>. Then add your image to that folder.</p><p>Next inside the pubspec.yaml you need to import that asset. For that under the flutter add a assets section and image like below.</p><pre>flutter:<br>  assets:<br>    - images/header.jpeg</pre><p>The next thing needs to do is provide decoration to <a href="https://api.flutter.dev/flutter/material/DrawerHeader-class.html">DrawerHeader</a>. In there you can use set image using <a href="https://api.flutter.dev/flutter/painting/DecorationImage-class.html">DecorationImage</a> widget. Please remember to set fit type a <a href="https://api.flutter.dev/flutter/painting/BoxFit-class.html">BoxFit.cover</a></p><pre>drawer: Drawer(<br>      child: ListView(<br>        padding: EdgeInsets.zero,<br>        children: [<br>          DrawerHeader(<br>            decoration: BoxDecoration(<br>              image: DecorationImage(<br>                image: AssetImage(&quot;images/header.jpeg&quot;),<br>                fit: BoxFit.cover<br>              )<br>            ),<br>            child: Text(&quot;Header&quot;),<br>          ),<br>          ListTile(<br>            title: Text(&quot;Home&quot;),<br>          )<br>        ],<br>      ),<br>  )</pre><h3>Navigation Drawer Sticky header</h3><p>When you add drawer items inside the ListView it will scroll the all the child content when scroll. If you want to change that to keep the header part sticky and move only the below items you have to do some changes to the widget structure</p><pre>Drawer(<br>      child: Column(<br>          children: [<br>            Expanded(<br>              flex: 1,<br>              child: Container(<br>                width: MediaQuery.of(context).size.width * 0.85,<br>                child: DrawerHeader(<br>                  decoration: BoxDecoration(<br>                      image: DecorationImage(<br>                          image: AssetImage(&quot;images/header.jpeg&quot;),<br>                          fit: BoxFit.cover)),<br>                  child: Text(&quot;Header&quot;),<br>                ),<br>              ),<br>            ),<br>            Expanded(<br>              flex: 2,<br>              child: ListView(children: [<br>                ListTile(<br>                  title: Text(&quot;Home&quot;),<br>                  onTap: () {<br>                    Navigator.of(context).pop();<br>                  },<br>                ),<br>                ListTile(<br>                  title: Text(&quot;Home&quot;),<br>                  onTap: () {<br>                    Navigator.of(context).pop();<br>                  },<br>                ),<br>                ListTile(<br>                  title: Text(&quot;Home&quot;),<br>                  onTap: () {<br>                    Navigator.of(context).pop();<br>                  },<br>                ),<br>                ListTile(<br>                  title: Text(&quot;Home&quot;),<br>                  onTap: () {<br>                    Navigator.of(context).pop();<br>                  },<br>                ),<br>                ListTile(<br>                  title: Text(&quot;Home&quot;),<br>                  onTap: () {<br>                    Navigator.of(context).pop();<br>                  },<br>                ),<br>                ListTile(<br>                  title: Text(&quot;Home&quot;),<br>                  onTap: () {<br>                    Navigator.of(context).pop();<br>                  },<br>                ),<br>                ListTile(<br>                  title: Text(&quot;Home&quot;),<br>                  onTap: () {<br>                    Navigator.of(context).pop();<br>                  },<br>                ),<br>                ListTile(<br>                  title: Text(&quot;Home&quot;),<br>                  onTap: () {<br>                    Navigator.of(context).pop();<br>                  },<br>                )<br>              ]),<br>            )<br>          ],<br>        ),<br>  )</pre><figure><img alt="Flutter Navigation drawer" src="https://cdn-images-1.medium.com/max/540/1*aOPCwbz6y7oVxuI_lcLOBw.png" /></figure><h3>Close Navigation Drawer programmatically</h3><p>It pretty easy to close the drawer programmatically. You just need only use the pop method in <a href="https://api.flutter.dev/flutter/widgets/Navigator-class.html">Navigation</a> class for the current context.</p><pre>ListTile(<br>            title: Text(&quot;Home&quot;),<br>            onTap: (){<br>              Navigator.of(context).pop();<br>            },<br>          )</pre><h3>Open Navigation Drawer programmatically</h3><p>First, you must set a key to the scaffold to identify. You can create a new object of <a href="https://api.flutter.dev/flutter/widgets/GlobalKey-class.html">GlobalKey</a> class and set that to the scaffold key. Then using that you can access the current state of the Scaffold and open the drawer by calling <a href="https://api.flutter.dev/flutter/material/ScaffoldState/openDrawer.html">openDrawer</a> method.</p><p>You can call this method from any button and in here I added a FlatButton to the body and from there I am going to open the drawer. You can also add a custom button to AppBar and trigger like this to open a drawer.</p><pre>final GlobalKey _scaffoldKey = new GlobalKey();</pre><p>Set key</p><pre>return Scaffold(<br>      key: _scaffoldKey<br>      ) // set key</pre><p>Trigger</p><pre>FlatButton(<br>              child: Text(&quot;Open Navigation&quot;),<br>              onPressed: (){<br>                _scaffoldKey.currentState.openDrawer();<br>              },<br>            ),</pre><h3>Navigation Drawer hamburger icon change and colour change</h3><p>If you are using <a href="https://api.flutter.dev/flutter/material/AppBar-class.html">Appbar</a> you can add leading Icon to replace the hamburger Icon. You can set IconButton for that and setting the colour will also change the Icon colour of that button.</p><p>But when you add a custom button it will lose the drawer open capability. But you can use the same old method to open the drawer programmatically by calling openDrawer method.</p><pre>appBar: AppBar(<br>  leading: IconButton(<br>    icon: Icon(Icons.gamepad,color: Colors.yellow,),<br>    onPressed: (){<br>      _scaffoldKey.currentState.openDrawer();<br>    },<br>   ),<br>   title: Text(widget.title),<br>  ),</pre><h3>Navigation Drawer in the right side</h3><p>It pretty easy to move drawer from left to right. When you are creating a drawer in the first place, it uses drawer option in Scaffold. You just need only to change that to endDrawer and the drawer will be open from the right. Also, hamburger menu will be move to the right.</p><pre>return Scaffold(<br>    key: _scaffoldKey,<br>   endDrawer: Drawer(<br>    child: ListView(<br>      padding: EdgeInsets.zero,<br>      children: [<br>        DrawerHeader(<br>          decoration: BoxDecoration(<br>            image: DecorationImage(<br>              image: AssetImage(&quot;images/header.jpeg&quot;),<br>              fit: BoxFit.cover<br>            )<br>          ),<br>          child: Text(&quot;Header&quot;),<br>        ),<br>        ListTile(<br>          title: Text(&quot;Home&quot;),<br>          onTap: (){<br>            Navigator.of(context).pop();<br>          },<br>        )<br>      ],<br>    ),<br>),</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*sV0HLcjkygWhlf9WEnQJmw.png" /></figure><h3>Custom Navigation drawer</h3><p>Drawer inside the Scaffold accepts Widget as a parameter. Therefore we can add custom widget without using Drawer widget inside the navigation.</p><p>In here I use Container as a main widget and wrap the other content inside that. Now when you test you will be able to see a full-screen drawer.</p><pre>drawer: Container(<br>    width: MediaQuery.of(context).size.width,<br>    height: MediaQuery.of(context).size.height,<br>    color: Colors.white,<br>    child: ListView(<br>      padding: EdgeInsets.zero,<br>      children: [<br>        DrawerHeader(<br>          decoration: BoxDecoration(<br>              image: DecorationImage(<br>                  image: AssetImage(&quot;images/header.jpeg&quot;),<br>                  fit: BoxFit.cover)),<br>          child: Text(&quot;Header&quot;),<br>        ),<br>        ListTile(<br>          title: Text(&quot;Home&quot;),<br>          onTap: () {<br>            Navigator.of(context).pop();<br>          },<br>        )<br>      ],<br>    ),<br>  ),</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*lu7Ww6zBerSGeyKR9KhqmQ.png" /></figure><h3>Conclusion</h3><p>I hope you get a better idea about navigation drawer implementation in Flutter and how to customize the drawer as you need. If you have any questions feel free to ask from me.</p><p><strong>Check the Full Video from here — </strong><a href="https://youtu.be/vmy9CLah_Lc"><strong>https://youtu.be/vmy9CLah_Lc</strong></a></p><p>Originally published at <a href="https://mightytechno.com/">https://mightytechno.com</a> on November 24, 2019.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66a60d27d687" width="1" height="1" alt=""><hr><p><a href="https://medium.com/shipkaro/flutter-navigation-drawer-from-basic-to-custom-drawer-66a60d27d687">Flutter Navigation Drawer from Basic to Custom Drawer</a> was originally published in <a href="https://medium.com/shipkaro">shipkaro — my journey to $10k</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Alert Dialog to Custom Dialog]]></title>
            <link>https://medium.com/shipkaro/flutter-alert-dialog-to-custom-dialog-966195157da8?source=rss-c6ddf75bc9ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/966195157da8</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-widget]]></category>
            <category><![CDATA[flutter-dialog]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[dialog]]></category>
            <dc:creator><![CDATA[Ishan Fernando]]></dc:creator>
            <pubDate>Fri, 15 Nov 2019 14:47:04 GMT</pubDate>
            <atom:updated>2021-07-28T02:00:58.563Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9AxIMG_FalalILgVTXwzEQ.png" /></figure><p>In the mobile apps, we use Dialog everywhere from alerting some situation to the user to get some feedback from the user.</p><p>We can use alert dialog to pause the user interaction with the current screen and show some intermediate action to the user like show error, take user email to process next step kind of stuff.</p><p>When comes to the Dialog in Flutter there are multiple ways of implement like</p><ol><li>Alert Dialog</li><li>Custom Dialog</li><li>Full-Screen Dialog</li></ol><h3>Flutter simple Alert Dialog</h3><p>Adding simple Dialog to your screen in pretty easy in Flutter.</p><p>Before adding Dialog you must call showDialog function to change current screen state to show the intermediate Dialog popup.</p><p>In here we use AlertDialog widget to show simple Dialog with title and some text in the body.</p><pre>showDialog(<br>              context: context,<br>              builder: (BuildContext context){<br>                  return AlertDialog(<br>                    title: Text(&quot;Alert Dialog&quot;),<br>                    content: Text(&quot;Dialog Content&quot;),<br>                  );<br>              }<br>            )</pre><p>Under the content, it does not required to add only the Text, you can add any widget like Image or something. But Because we use Alert Dialogs in simple use case, it better to show simple text or an image inside the content.</p><h4>Add buttons to Alert Dialogs</h4><p>In the AlertDialog widget, there is a parameter called action. ​It accepts arrays of widgets and you can provide multiple buttons to that. Those Buttons will appear in the bottom right corner of the dialog.</p><pre>            actions:[<br>                      FlatButton(<br>                        child: Text(&quot;Close&quot;),<br>                      )<br>                    ],</pre><h4>How to close Alert Dialogs</h4><p>In here we need to close the current Dialog when clicking Close button.</p><p>We can use the pop method in Navigator class for that.</p><pre>             FlatButton(<br>                        child: Text(&quot;Close&quot;),<br>                        onPressed: (){<br>                          Navigator.of(context).pop();<br>                        },<br>                      )</pre><h3>Flutter custom Alert Dialog</h3><p>Simple Alert Dialog will not be useful for every requirement. If you want to implement more advanced custom Dialog, you can use Dialog widget for that. Instead of the AlertDialog , in here we return Dialog widget. The showDialog method will remain the same.</p><p>You can use a Container widget to set relevant height for the Dialog.</p><p>Set the round corner to the Dialog by setting RoundedRectangleBorder for the shape and provide radius as you need.</p><pre>showDialog(<br>        context: context,<br>        builder: (BuildContext context) {<br>          return Dialog(<br>            shape: RoundedRectangleBorder(<br>                borderRadius:<br>                    BorderRadius.circular(20.0)), //this right here<br>            child: Container(<br>              height: 200,<br>              child: Padding(<br>                padding: const EdgeInsets.all(12.0),<br>                child: Column(<br>                  mainAxisAlignment: MainAxisAlignment.center,<br>                  crossAxisAlignment: CrossAxisAlignment.start,<br>                  children: [<br>                    TextField(<br>                      decoration: InputDecoration(<br>                          border: InputBorder.none,<br>                          hintText: &#39;What do you want to remember?&#39;),<br>                    ),<br>                    SizedBox(<br>                      width: 320.0,<br>                      child: RaisedButton(<br>                        onPressed: () {},<br>                        child: Text(<br>                          &quot;Save&quot;,<br>                          style: TextStyle(color: Colors.white),<br>                        ),<br>                        color: const Color(0xFF1BC0C5),<br>                      ),<br>                    )<br>                  ],<br>                ),<br>              ),<br>            ),<br>          );<br>        });</pre><h3>Flutter Full-Screen Dialog</h3><p>By Using showDialog method we cannot show full-screen Dialog. If we want to show dialog in full screen we must use showGeneralDialog method provided by Flutter SDK.</p><p>There are some interesting parameter available in showGeneralDialog method.</p><p><strong>barrierColor</strong> — Change dropshadow outside the dialog.</p><p><strong>transitionDuration</strong> — Animation duration</p><p><strong>barrierDismissible</strong> — Dismiss dialog by clicking outside in current route</p><pre>showGeneralDialog(<br>      context: context,<br>      barrierDismissible: true,<br>      barrierLabel: MaterialLocalizations.of(context)<br>          .modalBarrierDismissLabel,<br>      barrierColor: Colors.black45,<br>      transitionDuration: const Duration(milliseconds: 200),<br>      pageBuilder: (BuildContext buildContext,<br>          Animation animation,<br>          Animation secondaryAnimation) {<br>        return Center(<br>          child: Container(<br>            width: MediaQuery.of(context).size.width - 10,<br>            height: MediaQuery.of(context).size.height -  80,<br>            padding: EdgeInsets.all(20),<br>            color: Colors.white,<br>            child: Column(<br>              children: [<br>                RaisedButton(<br>                  onPressed: () {<br>                    Navigator.of(context).pop();<br>                  },<br>                  child: Text(<br>                    &quot;Save&quot;,<br>                    style: TextStyle(color: Colors.white),<br>                  ),<br>                  color: const Color(0xFF1BC0C5),<br>                )<br>              ],<br>            ),<br>          ),<br>        );<br>      });</pre><h3>Conclusion</h3><p>I hope you get a better idea about how to implement AlertDialog and How to convert that to a more customized version and how to show dialog in full screen.</p><blockquote><strong>Check the full video from here — </strong><a href="https://youtu.be/Wc90hrPyGBo"><strong>https://youtu.be/Wc90hrPyGBo</strong></a></blockquote><p>Originally published at <a href="https://mightytechno.com/">https://mightytechno.com</a> on November 9, 2019.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=966195157da8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/shipkaro/flutter-alert-dialog-to-custom-dialog-966195157da8">Flutter Alert Dialog to Custom Dialog</a> was originally published in <a href="https://medium.com/shipkaro">shipkaro — my journey to $10k</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Show clean log messages in Flutter using logger]]></title>
            <link>https://medium.com/mightytechno/show-clean-log-messages-in-flutter-using-logger-345db35101b9?source=rss-c6ddf75bc9ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/345db35101b9</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-plugin]]></category>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <dc:creator><![CDATA[Ishan Fernando]]></dc:creator>
            <pubDate>Wed, 09 Oct 2019 01:30:23 GMT</pubDate>
            <atom:updated>2019-11-08T13:40:47.729Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Hf2_5smeknW8wcXAJr1bw.png" /></figure><p>Logging is one of the crucial part when comes to identifying the issues in your Flutter app. But in the current flutter SDK, identify the actual log messages is kind of hard. Because all the things are mix in together in the terminal and it hard to find logs added by ourself and the logs created by the application itself. Hope google will provide better log mechanism for a flutter. Until that, we have a solution, Logger.</p><p><a href="https://pub.dev/packages/logger#-readme-tab-"><strong>Logger</strong></a> provides a nice, clean and easy way of adding the plugin to your Flutter application and it actually really beautiful. Without further delay let’s jump into the implementation</p><h3>Implementation</h3><p>First, add the plugin to your <strong>pubspec.yaml</strong> and press save to type <strong>flutter pub get</strong> to install the plugin to your flutter app</p><pre>logger: ^0.7.0+2</pre><p>Next import the plugin to the dart file where are you going to use this plugin.</p><pre>import &#39;package:logger/logger.dart&#39;;</pre><p>Next, create an instance of Logger class and call one of the logging methods to shows the actual logs. There are multiple log methods are available based on the conditions. Those are called as levels.</p><pre>var logger = Logger();<br>logger.d(&quot;Debug message&quot;);<br>logger.e(&quot;Error message&quot;);<br>logger.i(&quot;Info message&quot;);<br>logger.v(&quot;Verbose message&quot;);<br>logger.w(&quot;Warning message&quot;);<br>logger.wtf(&quot;WTF message&quot;);</pre><p>These are available <strong>levels</strong> and based on the level, it will change the color and other related parameters.</p><p><strong>verbose</strong> — Show detail of logging than the usual one</p><p><strong>debug</strong> — Use when log for debugging purpose</p><p><strong>info</strong> — Log info</p><p><strong>warning</strong> — Log warning messages</p><p><strong>error</strong> — Log error messages</p><p><strong>wtf</strong> — You know it right?</p><p>Based on the method you used, the output will be like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EAwsqP8yj7kq6ePXUjreSQ.png" /></figure><p>Pretty nice right?</p><p>Logger class also provide flexibility to change the look and feel of the logs based on your preference. For that, we can simply use Prettyprint instance and it provides the following customization</p><p><strong>colors</strong>- Show colorful logs</p><p><strong>errorMethodCount</strong> — No of error methods need to show</p><p><strong>printEmojis</strong> — Show emoji in log</p><p><strong>printTime</strong>- Show print time</p><p><strong>lineLength</strong> — Divider length</p><p><strong>methodCount</strong> — No of methods in Stacktrace</p><pre>var logger = Logger(printer: PrettyPrinter(<br>      colors: true,<br>      errorMethodCount: 1,<br>      printEmojis: true,<br>      printTime: true,<br>      lineLength: 80,<br>      methodCount: 0<br>    ));</pre><p>After the customization the output will be like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*XZlubL5jg4FI2Gbj9rJuIA.png" /></figure><h3>Add custom style to Log</h3><p>Adding more customization is also possible by adding a new implementation for LogPrinter. First, create a new class and extends LogPrinter and override the log method. When you call any of the log method this override method will be called. In here we can get an event as a parameter of the log method and it contains Level, Message, Error and Stacktrace.</p><pre>class CustomLog extends LogPrinter{<br><br>  @override<br>  void log(LogEvent event) {<br>    println(&#39;${event.message}&#39; );<br>  }<br>}</pre><p>If you want to add emojit also you can get those from <strong>levelEmojis</strong> static object in <strong>PrettyPrinter</strong> class like this.</p><pre>var emoji = PrettyPrinter.levelEmojis[event.level];</pre><h3>Filter the Logs</h3><p>In case if you want to show certain logs only, you can add a custom filter to the logger. Create a class and extends LogFilter and override the shouldLog method. In here if we return true, it will show all the logs. As an example, if we want to hide warning logs you have to modify the code like below</p><pre>class CustomFilter extends LogFilter{<br>  <br>  @override<br>  bool shouldLog(LogEvent event) {<br>    return event.level != Level.warning;<br>  }<br>}</pre><p>Now you can use these methods as your need for your next flutter application to show logs in a nice and clean way.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FGfCVLd7Zumg%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DGfCVLd7Zumg&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FGfCVLd7Zumg%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f75b360f585a5f9e6a83a03bf23620d/href">https://medium.com/media/7f75b360f585a5f9e6a83a03bf23620d/href</a></iframe><p><em>Originally published at </em><a href="https://mightytechno.com/clean-and-better-logs-in-flutter-using-logger/"><em>https://mightytechno.com</em></a><em> on October 9, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=345db35101b9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mightytechno/show-clean-log-messages-in-flutter-using-logger-345db35101b9">Show clean log messages in Flutter using logger</a> was originally published in <a href="https://medium.com/mightytechno">MightyTechno</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scan and Generate QR Code In Flutter]]></title>
            <link>https://medium.com/shipkaro/scan-and-generate-qr-code-in-flutter-99e4d346496b?source=rss-c6ddf75bc9ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/99e4d346496b</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[qr-code]]></category>
            <category><![CDATA[qr-scan-flutter]]></category>
            <category><![CDATA[flutter-ui]]></category>
            <category><![CDATA[qr-generate]]></category>
            <dc:creator><![CDATA[Ishan Fernando]]></dc:creator>
            <pubDate>Tue, 01 Oct 2019 16:36:22 GMT</pubDate>
            <atom:updated>2020-02-26T01:38:12.502Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zee5JRKlHMD9zdZ10cMyww.jpeg" /></figure><p>Do you have got any requirement to implement barcode read or barcode generate flow to your application? Then this article is for you. I will cover how to add QR generate and scan feature to your application with two nice plugins. Before further delay let’s first talk about QR generate part</p><h3>QR Generate</h3><p>Even though multiple plugins available for the QR reader, this plugin contains a detail explanation with an example. So it will be easy for you to implement it.</p><p>First, create a new flutter project and add<a href="https://pub.dev/packages/qr_flutter#-readme-tab-"> this plugin</a> to your pubspec.yaml under the dependencies</p><pre>qr_flutter: ^3.0.1</pre><p>Then open the terminal and type <strong>flutter pub get</strong> and it will download the necessary plugin component to your project.</p><pre>flutter pub get</pre><p>Next open the main.dart file or the file which you are going to use QR widget and import the plugin like this</p><pre>import &#39;package:qr_flutter/qr_flutter.dart&#39;;</pre><p>Now the setup part is done and dusted.</p><p>Finally, you should add the widget where the QR code is going to display. When adding QR widget the only required property is data. In there you must past the data which need to represent as a QR. In here I use some simple text. You can use whatever text you want.</p><pre>QrImage( data: &quot;this is qr&quot;, )</pre><p>Other than that property there are very useful optional properties also available and These are some of them.</p><p><strong>version</strong> — Version of the QR. <a href="https://www.qrcode.com/en/about/version.html">Check this</a> to learn about this</p><ul><li><strong>size</strong> — Set the size of the QR widget</li><li><strong>backgroundColor</strong> — Set background colour of the QR</li><li><strong>embeddedImage</strong> — Add image center of the QR. Like your logo or something.</li></ul><p>So that all about QR generate in Flutter and next move to the QR Scan part.</p><h3>Scan QR</h3><p>Scanning the QR in flutter will require a little bit of code than generate. But don’t panic it just a little bit, not much.</p><p>First of all, you need to add <a href="https://github.com/AmolGangadhare/flutter_barcode_scanner">Flutter barcode scanner</a> plugin to your project. Wait what? barcode scanner? Yes actually. This will allow you to scan the barcode as well as QR.</p><pre>flutter_barcode_scanner: ^0.1.7</pre><p>Next import the plugin to your main.dart or whatever file which you are going to use this library.</p><pre>import &#39;package:flutter_barcode_scanner/flutter_barcode_scanner.dart&#39;;</pre><p>After that, you need to call <strong><em>scanBarcode</em></strong> static method inside FlutterBarcodeScanner class and It will return the scanned result. This call must happen inside the async method and you can implement it like this in below.</p><pre>Future scanBarcodeNormal() async {<br>    String barcodeScanRes;<br><br>      barcodeScanRes = await FlutterBarcodeScanner.scanBarcode(<br>          &quot;#ff6666&quot;, &quot;Cancel&quot;, true, ScanMode.QR);<br>      print(barcodeScanRes);<br><br>    setState(() {<br>      _scanBarcode = barcodeScanRes;<br>    });<br>  }</pre><p>In here we can customize a few things.</p><p>The first property is <strong>line colours</strong> which are moving up and down until the scan completes. Second property is the <strong>text of the cancel button</strong> and the third is indicate whether we need to <strong>show Flash icon or not. The last one defines</strong> the type whether it’s a QR or a barcode.</p><p>In here I set the <strong>barcodeScanRes</strong> to the <strong>_scanBarcode</strong> variable and you can show that value in the UI.</p><p>Now you can try this in a real device and you can see the QR result will assign to the <strong>_scanBarcode</strong> variable and If you have set that to show it somewhere it will appear.</p><p>Hope you get an idea about how to implement QR Scan and Generate in Flutter application and If you have further question please let me know in the comment.</p><p>You can check all the samples inside <a href="https://github.com/IshanFx/Flutter-Samples">this repo</a></p><p>Happy coding 😀</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F9WrFx32ROUQ%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D9WrFx32ROUQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F9WrFx32ROUQ%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b728363c06648404fb8401c80429c3d/href">https://medium.com/media/0b728363c06648404fb8401c80429c3d/href</a></iframe><p><em>Originally published at </em><a href="https://mightytechno.com/scan-and-generate-qr-code-in-flutter/"><em>https://mightytechno.com</em></a><em> on October 1, 2019.</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fnprzfz%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2Fnprzfz&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/04b1ebb50b50db827f1dd02834ac9f93/href">https://medium.com/media/04b1ebb50b50db827f1dd02834ac9f93/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99e4d346496b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/shipkaro/scan-and-generate-qr-code-in-flutter-99e4d346496b">Scan and Generate QR Code In Flutter</a> was originally published in <a href="https://medium.com/shipkaro">shipkaro — my journey to $10k</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Boring Tab to Cool Tab]]></title>
            <link>https://medium.com/shipkaro/flutter-boring-tab-to-cool-tab-bfcb1a93f8d0?source=rss-c6ddf75bc9ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfcb1a93f8d0</guid>
            <category><![CDATA[flutter-tab-indicator]]></category>
            <category><![CDATA[flutter-tabs]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-tab-style]]></category>
            <category><![CDATA[flutter-widget]]></category>
            <dc:creator><![CDATA[Ishan Fernando]]></dc:creator>
            <pubDate>Wed, 10 Jul 2019 13:41:39 GMT</pubDate>
            <atom:updated>2020-02-26T01:38:53.520Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EgY-Fot9DVG7YsHXiBRgCw.png" /></figure><p>The default tabs styles provided by the flutter is kind of boring. But It doesn’t say we cannot customize the look and the feel of the tab.</p><p>Best and easy customization can be done by changing the tab indicator. In this article, I will show you how to add 5 different tab styles for our next app.</p><p>First, we need to create a basic tab. In here I used DefaultTabController.You can assign DefaultTabController to a home parameter of the MaterialApp widget. For the child of DefaultTabController, you can use Scaffold with the <strong>appbar</strong> and the body. For the <strong>appBar</strong> you can assign Appbar widget to make header part of the tabs. For the body, you can add the TabBarView widget with the 3 child Widgets to show the item when you click the tabs.</p><p>Check the full code for the default tab.</p><pre>DefaultTabController(<br>        length: 3,<br>        child: Scaffold(<br>          appBar: AppBar(<br>            elevation: 0,<br>            bottom: TabBar(indicatorSize: TabBarIndicatorSize.label, tabs: [<br>              Tab(<br>                child: Align(<br>                  alignment: Alignment.center,<br>                  child: Text(&quot;APPS&quot;),<br>                ),<br>              ),<br>              Tab(<br>                child: Align(<br>                  alignment: Alignment.center,<br>                  child: Text(&quot;MOVIES&quot;),<br>                ),<br>              ),<br>              Tab(<br>                child: Align(<br>                  alignment: Alignment.center,<br>                  child: Text(&quot;GAMES&quot;),<br>                ),<br>              ),<br>            ]),<br>          ),<br>          body: TabBarView(children: [<br>            Icon(Icons.apps),<br>            Icon(Icons.movie),<br>            Icon(Icons.games),<br>          ]),<br>        )<br>    )</pre><h3>1.Round Corners</h3><p>In here we are going to add a round corner style to the tab indicator. First of all, I will give a brief description of the param which we are going to modify.</p><p>Round corner style can be done by adding BoxDecoration with borderRadius 50.</p><p>Then I will add a red colour border to each tab headers. When you selected the tab It will fill with the red colour. If you are not interested in the border, you can just remove the border adding the part and keep it simple.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*j8x721n5W7vwWQincVnhCg.png" /></figure><pre>DefaultTabController(<br>      length: 3,<br>      child: Scaffold(<br>        appBar: AppBar(<br>          backgroundColor: Colors.white,<br>          elevation: 0,<br>          bottom: TabBar(<br>              unselectedLabelColor: Colors.redAccent,<br>              indicatorSize: TabBarIndicatorSize.label,<br>              indicator: BoxDecoration(<br>                  borderRadius: BorderRadius.circular(50),<br>                  color: Colors.redAccent),<br>              tabs: [<br>                Tab(<br>                  child: Container(<br>                    decoration: BoxDecoration(<br>                        borderRadius: BorderRadius.circular(50),<br>                        border: Border.all(color: Colors.redAccent, width: 1)),<br>                    child: Align(<br>                      alignment: Alignment.center,<br>                      child: Text(&quot;APPS&quot;),<br>                    ),<br>                  ),<br>                ),<br>                Tab(<br>                  child: Container(<br>                    decoration: BoxDecoration(<br>                        borderRadius: BorderRadius.circular(50),<br>                        border: Border.all(color: Colors.redAccent, width: 1)),<br>                    child: Align(<br>                      alignment: Alignment.center,<br>                      child: Text(&quot;MOVIES&quot;),<br>                    ),<br>                  ),<br>                ),<br>                Tab(<br>                  child: Container(<br>                    decoration: BoxDecoration(<br>                        borderRadius: BorderRadius.circular(50),<br>                        border: Border.all(color: Colors.redAccent, width: 1)),<br>                    child: Align(<br>                      alignment: Alignment.center,<br>                      child: Text(&quot;GAMES&quot;),<br>                    ),<br>                  ),<br>                ),<br>              ]),<br>        ),<br>        body: TabBarView(children: [<br>          Icon(Icons.apps),<br>          Icon(Icons.movie),<br>          Icon(Icons.games),<br>        ]),<br>      ))</pre><h3>2.Round Corners with Gradient</h3><p>In here I removed the style which I was added to each tab. After that added a gradient to BoxDecoration. In here I used LinearGradient with two colours. You can change the gradient-based on your preferences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*icJvrGtBIUQJmEDodBvjNw.png" /></figure><pre>DefaultTabController(<br>        length: 3,<br>        child: Scaffold(<br>          appBar: AppBar(<br>            backgroundColor: Colors.white,<br>            elevation: 0,<br>            bottom: TabBar(<br>                unselectedLabelColor: Colors.redAccent,<br>                indicatorSize: TabBarIndicatorSize.tab,<br>                indicator: BoxDecoration(<br>                    gradient: LinearGradient(<br>                        colors: [Colors.redAccent, Colors.orangeAccent]),<br>                    borderRadius: BorderRadius.circular(50),<br>                    color: Colors.redAccent),<br>                tabs: [<br>                  Tab(<br>                    child: Align(<br>                      alignment: Alignment.center,<br>                      child: Text(&quot;APPS&quot;),<br>                    ),<br>                  ),<br>                  Tab(<br>                    child: Align(<br>                      alignment: Alignment.center,<br>                      child: Text(&quot;MOVIES&quot;),<br>                    ),<br>                  ),<br>                  Tab(<br>                    child: Align(<br>                      alignment: Alignment.center,<br>                      child: Text(&quot;GAMES&quot;),<br>                    ),<br>                  ),<br>                ]),<br>          ),<br>          body: TabBarView(children: [<br>            Icon(Icons.apps),<br>            Icon(Icons.movie),<br>            Icon(Icons.games),<br>          ]),<br>        )<br>     )</pre><h3>3.Square Style</h3><p>Square style can be done by changing the small code in the previous one. <strong>BorderRadius</strong> of the <strong>boxDecoration</strong> can be changed by adding 10 for both leftTop and rightTop. Then I change the <strong>appbar</strong> backgroundColor to the red to make it look better.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*5FdqaHzlLfM_YzzdA7Ht_A.png" /></figure><pre>DefaultTabController(<br>        length: 3,<br>        child: Scaffold(<br>          appBar: AppBar(<br>            backgroundColor: Colors.redAccent,<br>            elevation: 0,<br>            bottom: TabBar(<br>                labelColor: Colors.redAccent,<br>                unselectedLabelColor: Colors.white,<br>                indicatorSize: TabBarIndicatorSize.label,<br>                indicator: BoxDecoration(<br>                    borderRadius: BorderRadius.only(<br>                        topLeft: Radius.circular(10),<br>                        topRight: Radius.circular(10)),<br>                    color: Colors.white),<br>                tabs: [<br>                  Tab(<br>                    child: Align(<br>                      alignment: Alignment.center,<br>                      child: Text(&quot;APPS&quot;),<br>                    ),<br>                  ),<br>                  Tab(<br>                    child: Align(<br>                      alignment: Alignment.center,<br>                      child: Text(&quot;MOVIES&quot;),<br>                    ),<br>                  ),<br>                  Tab(<br>                    child: Align(<br>                      alignment: Alignment.center,<br>                      child: Text(&quot;GAMES&quot;),<br>                    ),<br>                  ),<br>                ]<br>            ),<br>          ),<br>          body: TabBarView(children: [<br>            Icon(Icons.apps),<br>            Icon(Icons.movie),<br>            Icon(Icons.games),<br>          ]),<br>        )<br>     )</pre><h3>4.Diamond Style</h3><p>Diamond tab style can be done by adding ShapeDecoration with BeveledRectangleBorder for the shape parameter.BeveledRectangleBorder will allow you to add flatten corner instead of round corners.</p><blockquote><em>The line segments that connect the rectangle’s four sides will begin and at locations offset by the corresponding border radius, but not farther than the side’s center. If all the border radii exceed the sides’ half widths/heights the resulting shape is diamond made by connecting the centers of the sides.</em></blockquote><blockquote><em>BeveledRectangleBorder — flutter.dev</em></blockquote><p>In here I used borderRadius as 10 to make it look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*tTZz60fW_5lXLERCUFzQ9g.png" /></figure><pre>DefaultTabController(<br>        length: 3,<br>        child: Scaffold(<br>          appBar: AppBar(<br>            backgroundColor: Colors.white,<br>            elevation: 0,<br>            bottom: TabBar(<br>                unselectedLabelColor: Colors.redAccent,<br>                indicatorPadding: EdgeInsets.only(left: 30, right: 30),<br>                indicator: ShapeDecoration(<br>                    color: Colors.redAccent,<br>                    shape: BeveledRectangleBorder(<br>                        borderRadius: BorderRadius.circular(10),<br>                        side: BorderSide(<br>                          color: Colors.redAccent,<br>                        )<br>                    )<br>                ),<br>                tabs: [<br>                  Tab(<br>                    child: Align(<br>                      alignment: Alignment.center,<br>                      child: Text(&quot;APPS&quot;),<br>                    ),<br>                  ),<br>                  Tab(<br>                    child: Align(<br>                      alignment: Alignment.center,<br>                      child: Text(&quot;MOVIES&quot;),<br>                    ),<br>                  ),<br>                  Tab(<br>                    child: Align(<br>                      alignment: Alignment.center,<br>                      child: Text(&quot;GAMES&quot;),<br>                    ),<br>                  ),<br>                ]),<br>          ),<br>          body: TabBarView(children: [<br>            Icon(Icons.apps),<br>            Icon(Icons.movie),<br>            Icon(Icons.games),<br>          ]),<br>        )<br>     )</pre><h3>5.Diamond Style 2</h3><p>Likewise, by changing the borderRadius of the BeveledRectangleBorder, you can achieve different styles. In here I used borderRadius as 20. You can try different styles by changing this borderRadius value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*XsPhv3e5FtZVW2eSPMQscA.png" /></figure><pre>DefaultTabController(<br>        length: 3,<br>        child: Scaffold(<br>          appBar: AppBar(<br>            backgroundColor: Colors.white,<br>            elevation: 0,<br>            bottom: TabBar(<br>                unselectedLabelColor: Colors.redAccent,<br>                indicatorPadding: EdgeInsets.only(left: 30, right: 30),<br>                indicator: ShapeDecoration(<br>                    color: Colors.redAccent,<br>                    shape: BeveledRectangleBorder(<br>                        borderRadius: BorderRadius.circular(20),<br>                        side: BorderSide(<br>                          color: Colors.redAccent,<br>                        ))),<br>                tabs: [<br>                  Tab(<br>                    child: Align(<br>                      alignment: Alignment.center,<br>                      child: Text(&quot;APPS&quot;),<br>                    ),<br>                  ),<br>                  Tab(<br>                    child: Align(<br>                      alignment: Alignment.center,<br>                      child: Text(&quot;MOVIES&quot;),<br>                    ),<br>                  ),<br>                  Tab(<br>                    child: Align(<br>                      alignment: Alignment.center,<br>                      child: Text(&quot;GAMES&quot;),<br>                    ),<br>                  ),<br>                ]),<br>          ),<br>          body: TabBarView(children: [<br>            Icon(Icons.apps),<br>            Icon(Icons.movie),<br>            Icon(Icons.games),<br>          ]),<br>        )<br>     )</pre><p>I hope you get a better understanding of how to change the tab style by a few lines of code. If you are like to watch this in action, please watch the video mentioned below. 🤗</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FVnd0yvCkdNA%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVnd0yvCkdNA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FVnd0yvCkdNA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a3fa470366ed6532b7ba9964037f76d/href">https://medium.com/media/2a3fa470366ed6532b7ba9964037f76d/href</a></iframe><h3>References</h3><p><a href="https://flutter.dev/docs/cookbook/design/tabs">https://flutter.dev/docs/cookbook/design/tabs</a> <a href="https://api.flutter.dev/flutter/painting/BeveledRectangleBorder-class.html">https://api.flutter.dev/flutter/painting/BeveledRectangleBorder-class.html</a></p><p><em>Originally published at </em><a href="https://mightytechno.com/flutter-boring-tab-to-cool-tab/"><em>https://mightytechno.com</em></a><em> on July 10, 2019.</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fnprzfz%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2Fnprzfz&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/04b1ebb50b50db827f1dd02834ac9f93/href">https://medium.com/media/04b1ebb50b50db827f1dd02834ac9f93/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfcb1a93f8d0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/shipkaro/flutter-boring-tab-to-cool-tab-bfcb1a93f8d0">Flutter Boring Tab to Cool Tab</a> was originally published in <a href="https://medium.com/shipkaro">shipkaro — my journey to $10k</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Animate the Button Size with Position]]></title>
            <link>https://ishanfx.medium.com/flutter-animate-the-button-size-with-position-3d6f2e218598?source=rss-c6ddf75bc9ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d6f2e218598</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter-animation]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[button-animation]]></category>
            <category><![CDATA[flutter-button]]></category>
            <dc:creator><![CDATA[Ishan Fernando]]></dc:creator>
            <pubDate>Sat, 04 May 2019 01:15:13 GMT</pubDate>
            <atom:updated>2019-07-05T17:31:01.387Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0AajuvkYDAns72xmvWZV5g.png" /></figure><p>In the last tutorial, I show the way of adding a nice show and hide animation to the button. In this article, I am gone an add some improvement to that animation.</p><p>If you didn’t check my first article read it first</p><p><a href="https://medium.com/flutterpub/flutter-button-animation-15cf934de010">Flutter Button Animation</a></p><p>In here I will improve that by adding nice animation to change the button scale while the position animation happening.</p><p>For that, we need to create another Animation object and It also a Tween animation. Because of changing the scale in this animation I will change the value from 0 to 1 in here.</p><p>After that, you can wrap the FloatingActionButton widget with Transform.scale widget to change the size when the value changes from 0 to 1.</p><p>In here I use 3 buttons. The button is in the top of the stack change scale from 1 to 0 when clicking it and it will show the button which is on below that. While that animation occurs the button which is the bottom of the stack will change the position.</p><p>The end of the animation the button in the top of the stack get disappear and show the button in the middle.</p><p>When you click the button in the middle it reverses the animation and shows the button in the top of the stack.</p><pre>class _MyHomePageState extends State with SingleTickerProviderStateMixin {<br>  <br>  AnimationController animationController;<br>  Animation animation;<br>  Animation sizeAnimation;<br>  int currentState = 0;<br><br>  @override<br>  void initState() {<br>    // TODO: implement initState<br>    super.initState();<br>    animationController = AnimationController(duration: Duration(milliseconds: 500),vsync: this);<br>    animation = Tween(begin: 0,end: 60).animate(animationController)..addListener((){<br>      setState(() {<br>        <br>      });<br>    });<br>    sizeAnimation = Tween(begin: 0,end: 1).animate(CurvedAnimation(parent: animationController,curve: Curves.fastOutSlowIn))..addListener((){<br>      setState(() {<br>        <br>      });<br>    });<br>  }<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(<br>        title: Text(widget.title),<br>      ),<br>      body: Center(<br>        child: Container(<br>          width: 200,<br>          height: 300,<br>          child: Stack(<br>            children: [<br>              Positioned(<br>                bottom: animation.value,<br>                child: Transform.scale(<br>                    scale: sizeAnimation.value,<br>                    child: FloatingActionButton(<br>                    backgroundColor: Colors.redAccent,<br>                    onPressed: (){},<br>                    child: Icon(Icons.cake)),<br>                ),<br>              ),<br>              Positioned(<br>                bottom: 0,<br>                <br>                child: Transform.scale(<br>                  scale: sizeAnimation.value,<br>                    child: FloatingActionButton(<br>                    backgroundColor: Colors.green,<br>                    onPressed: (){<br>                      animationController.reverse();<br>                    },<br>                    child: Icon(Icons.close)),<br>                ),<br>              ),<br>              Positioned(<br>                bottom: 0,<br>                child: Transform.scale(<br>                  scale: sizeAnimation.value - 1,<br>                   child: FloatingActionButton(<br>                    onPressed: (){<br>                      animationController.forward();<br>                    <br>                    },<br>                    child: Icon(Icons.add)),<br>                ),<br>              )<br>            ],<br>          ),<br>        ),<br>      )<br>    );<br>  }<br>}</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F1FH6RwwBPIE%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D1FH6RwwBPIE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F1FH6RwwBPIE%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2935e96f786d688b0d7a37021217c886/href">https://medium.com/media/2935e96f786d688b0d7a37021217c886/href</a></iframe><p><em>Originally published at </em><a href="https://mightytechno.com/flutter-animate-the-button-size/"><em>https://mightytechno.com</em></a><em> on May 4, 2019.</em></p><p>Reference</p><p><a href="https://flutter.dev/docs/development/ui/animations">https://flutter.dev/docs/development/ui/animations</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d6f2e218598" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>