<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aakashp</title>
    <description>The latest articles on DEV Community by Aakashp (@aakashp).</description>
    <link>https://dev.to/aakashp</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F672094%2Fdd34b006-c314-44c0-b8d8-e9e854cab844.png</url>
      <title>DEV Community: Aakashp</title>
      <link>https://dev.to/aakashp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aakashp"/>
    <language>en</language>
    <item>
      <title>Automatic Show/Hide FAB on scroll in Flutter</title>
      <dc:creator>Aakashp</dc:creator>
      <pubDate>Mon, 09 Jan 2023 18:03:36 +0000</pubDate>
      <link>https://dev.to/aakashp/automatic-showhide-fab-on-scroll-in-flutter-3lc8</link>
      <guid>https://dev.to/aakashp/automatic-showhide-fab-on-scroll-in-flutter-3lc8</guid>
      <description>&lt;p&gt;Hello readers, Welcome back to another article on flutter.&lt;/p&gt;

&lt;p&gt;In this we will see how to hide or show the Floating action button in flutter app when the user scrolls the screen.&lt;/p&gt;

&lt;p&gt;Sometimes it is required to hide the FAB button when user scrolls because it blocks the behind view of the screen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So this is what we want to do today.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uuoAjMU8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://miro.medium.com/max/750/1%2AT7AFJnzpcjgSkGbaLWGeoQ.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uuoAjMU8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://miro.medium.com/max/750/1%2AT7AFJnzpcjgSkGbaLWGeoQ.gif" alt="Task To Achieve Today" width="600" height="1248"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating Scroll View&lt;/strong&gt;&lt;br&gt;
First create a screen with any scrolling view like list view or grid view in it and a Floating action button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EkmvPljN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bwi9w0adtws08zfjgkwl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EkmvPljN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bwi9w0adtws08zfjgkwl.png" alt="Code" width="880" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now to hide the fab on scroll we need to listen to the scrolling events of scroll view.&lt;br&gt;
To listen to the scrolling events we need to give the scroll view a custom scroll controller.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LiS0cUcG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tja1ma8zmdmo6ky83kdl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LiS0cUcG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tja1ma8zmdmo6ky83kdl.png" alt="Code" width="828" height="665"&gt;&lt;/a&gt;&lt;br&gt;
Now we can listen to the scroll events of this list view by add callback to the scroll controller .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating Custom FAB&lt;/strong&gt;&lt;br&gt;
Now create a custom Floating action button which will hide/show automatically based on the scroll event. To do this first create a stateful widget and return FAB in the build method.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dvpE6-Wx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ce5h2o2ds1qw0fto18oe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dvpE6-Wx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ce5h2o2ds1qw0fto18oe.png" alt="Code" width="828" height="403"&gt;&lt;/a&gt;&lt;br&gt;
Now wrap this FAB inside visibility widget to hide or show the Fab.&lt;br&gt;
Create a Boolean variable &lt;strong&gt;isVisible&lt;/strong&gt; to control the visibility of the visibility widget.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yIaoogys--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0jn2jste8ucmpwfwazvr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yIaoogys--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0jn2jste8ucmpwfwazvr.png" alt="Code" width="828" height="331"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now in the constructor of this &lt;strong&gt;CustomFab&lt;/strong&gt; widget add a parameter of Scroll Controller. So that we can listen scroll events in this widget.&lt;/p&gt;

&lt;p&gt;In the &lt;strong&gt;initState&lt;/strong&gt; method of this widget add a callback to this scroll controller.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hTiRFp7I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hb87bi2tk68wjzjjnpam.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hTiRFp7I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hb87bi2tk68wjzjjnpam.png" alt="Code" width="828" height="712"&gt;&lt;/a&gt;&lt;br&gt;
Now add a condition that if user scroll down make isVisible to false and if user scrolls up name isVisible to true.&lt;/p&gt;

&lt;p&gt;To do this we can use the &lt;strong&gt;controller.position.userScrollDirection&lt;/strong&gt; property of controller. This will give the direction in which the user is scrolling(forward or reverse).&lt;/p&gt;

&lt;p&gt;Using this we can add a if condition in callback to show / hide our FAB and update the UI by calling &lt;strong&gt;setState&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GvQrj8WG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/54ej4qlb3dxqfryaue4n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GvQrj8WG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/54ej4qlb3dxqfryaue4n.png" alt="Code" width="828" height="593"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;set the visible parameter of Visibility widget to &lt;strong&gt;isVisible&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rQItKRe4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mcil6jpxqoazj6gwbknr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rQItKRe4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mcil6jpxqoazj6gwbknr.png" alt="Code" width="828" height="236"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Another Example&lt;/strong&gt;&lt;br&gt;
Using similar method we can also achieve something like this with extended Floating action button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vL7UeS-S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://miro.medium.com/max/750/1%2AB_y_0ihuHhsro4NTHj8Ahw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vL7UeS-S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://miro.medium.com/max/750/1%2AB_y_0ihuHhsro4NTHj8Ahw.gif" alt="Code" width="600" height="1248"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Follow Me
&lt;/h2&gt;

&lt;p&gt;Thanks For reading this article until now, If you liked this than you can also read more articles and follow me.&lt;br&gt;
&lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://medium.com/@aakashpp" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://res.cloudinary.com/practicaldev/image/fetch/s--_fvbQTG5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/2400/1%2AdmbNkD5D-u45r44go_cf0g.png" height="500" class="m-0" width="500"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://medium.com/@aakashpp" rel="noopener noreferrer" class="c-link"&gt;
          Aakashp – Medium
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          Read writing from Aakashp on Medium. Flutter, Java, developer. | Trying to explain concepts in the most straightforward way possible. Every day, Aakashp and thousands of other voices read, write, and share important stories on Medium.
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://res.cloudinary.com/practicaldev/image/fetch/s--0sTL1rzS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/1%2Am-R_BkNf1Qjr1YbyOIJY2w.png" width="32" height="32"&gt;
        medium.com
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;div class="ltag__user ltag__user__id__672094"&gt;
    &lt;a href="/aakashp" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qhRSn0Y7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--L7APHWLz--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/672094/dd34b006-c314-44c0-b8d8-e9e854cab844.png" alt="aakashp image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/aakashp"&gt;Aakashp&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/aakashp"&gt;&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;a href="https://twitter.com/Aakash_P_" rel="noopener noreferrer"&gt;
      twitter.com
    &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>flutter</category>
      <category>beginners</category>
      <category>dart</category>
    </item>
    <item>
      <title>Understanding Flutter Pageview Widget(Making Instagram reels screen)</title>
      <dc:creator>Aakashp</dc:creator>
      <pubDate>Sun, 24 Jul 2022 17:05:00 +0000</pubDate>
      <link>https://dev.to/aakashp/understanding-flutter-pageview-widgetmaking-instagram-reels-screen-4od2</link>
      <guid>https://dev.to/aakashp/understanding-flutter-pageview-widgetmaking-instagram-reels-screen-4od2</guid>
      <description>&lt;p&gt;Hello readers, welcome back to another article. in the previous article we saw in detail about dismissible widget which we can use to implement slide to delete like the Gmail app.&lt;/p&gt;

&lt;p&gt;Today in this article will see in detail the Pageview widget in flutter.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm4evu50f7zrnxdpclpzy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm4evu50f7zrnxdpclpzy.png" alt="Thumbnail"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  What is Pageview Widget?
&lt;/h3&gt;

&lt;p&gt;Pageview widget is similar to the list view. The only difference is the list view is used to show the list of items on a single screen whereas the page view shows a list of pages to scroll.&lt;/p&gt;

&lt;p&gt;A pageview is useful when you want to show a list of full-screen images or videos or any other data. As you have seen in Instagram reels we see a video on a full page and when we scroll to another reel it's a different page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Understanding Page View Constructor&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PageView PageView({
  Key? key,
  Axis scrollDirection = Axis.horizontal,
  bool reverse = false,
  PageController? controller,
  ScrollPhysics? physics,
  bool pageSnapping = true,
  void Function(int)? onPageChanged,
  List&amp;lt;Widget&amp;gt; children = const &amp;lt;Widget&amp;gt;[],
  DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  bool allowImplicitScrolling = false,
  String? restorationId,
  Clip clipBehavior = Clip.hardEdge,
  ScrollBehavior? scrollBehavior,
  bool padEnds = true,
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see in the constructor there are many different parameters we can tweak within the page view.&lt;/p&gt;

&lt;p&gt;Let's see each of them one by one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scroll Direction&lt;/strong&gt;&lt;br&gt;
As the name suggests it is the direction in which we want our page view to scroll. Example Horizontal, Vertical.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F750%2F1%2AsFuayjvzzghh2UUH2BtyTA.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F750%2F1%2AsFuayjvzzghh2UUH2BtyTA.gif" alt="ScrollDirection 1"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F750%2F1%2Aly-bvJ3jsy_R4iDJJ4U0sA.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F750%2F1%2Aly-bvJ3jsy_R4iDJJ4U0sA.gif" alt="ScrollDirection 2"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Reverse&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is a Boolean value that reverses the scroll direction if set to true and default if false.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F750%2F1%2APanmh642_1ziJtuEaxveoQ.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F750%2F1%2APanmh642_1ziJtuEaxveoQ.gif" alt="Reverse"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Controller&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The controller is a Page Controller which we can use to change the behavior of page view as per our requirements like in List view.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Physics&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Physics defines the scroll behavior of the page view. There are multiple options like&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;NoScrollPhysics&lt;/li&gt;
&lt;li&gt;BouncyScrollPhysics&lt;/li&gt;
&lt;li&gt;and many other
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F750%2F1%2ACnAWZ3NDWjfjeXWOArZFjQ.gif" alt="BouncyScrollPhysics"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Page Snapping&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is also a boolean value which is when true the page will automatically drag to fit the screen while scrolling and if set false then the page will stop in between.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;onPageChange&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;onPageChange is a function callback with one int parameter. This function is called whenever the page is changed in the page view. The int parameter represents the index of the page.&lt;/p&gt;

&lt;p&gt;Here we will show a snack bar with the index of the page whenever the page changes in page view.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; onPageChanged: (int) {
        ScaffoldMessenger.of(context)
            .showSnackBar(SnackBar(content: Text("Page $int")));
      },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F750%2F1%2AgSXrJnRF70NKeyHARN-zmw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F750%2F1%2AgSXrJnRF70NKeyHARN-zmw.gif" alt="onPageChange"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Children&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Children are the list of widgets that are to be shown in the page view.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; children: [
        Container(
          color: Colors.amberAccent,
        ),
        Container(
          color: Colors.red,
        ),
        Container(
          color: Colors.blue,
        ),
        Container(
          color: Colors.green,
        )
      ],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;drag start behavior (from flutter docs)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Determines the way that drag start behavior is handled.&lt;/p&gt;

&lt;p&gt;If set to [DragStartBehavior.start], scrolling drag behavior will begin at the position where the drag gesture won the arena. If set to [DragStartBehavior.down] it will begin at the position where a down event is first detected.&lt;/p&gt;

&lt;p&gt;In general, setting this to [DragStartBehavior.start] will make drag animation smoother, and setting it to [DragStartBehavior.down] will make drag behavior feel slightly more reactive.&lt;/p&gt;

&lt;p&gt;By default, the drag start behavior is [DragStartBehavior.start].&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;allowImplicitScrolling&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is also a Boolean field that has no effect on normal users. It will be useful when the user is using the app via accessibility.&lt;/p&gt;

&lt;p&gt;Controls whether the widget's pages will respond to [RenderObject.showOnScreen], allowing for implicit accessibility scrolling.&lt;/p&gt;

&lt;p&gt;With this flag set to false, when accessibility focus reaches the end of the current page and the user attempts to move it to the next element, the focus will traverse to the next widget outside of the page view.&lt;/p&gt;

&lt;p&gt;With this flag set to true, when accessibility focus reaches the end of the current page and the user attempts to move it to the next element, the focus will traverse to the next page in the page view.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;restorationId&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Restoration ID to save and restore the scroll offset of the scrollable.&lt;/p&gt;

&lt;p&gt;If a restoration id is provided, the scrollable will persist its current scroll offset and restore it during state restoration.&lt;/p&gt;

&lt;p&gt;The scroll offset is persisted in a [RestorationBucket] claimed from the surrounding [RestorationScope] using the provided restoration ID.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;clipBehavior&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;clipBehavior is the parameter that defines what to do when the content of the page view goes outside of its boundary. There are multiple options available for clips like&lt;/p&gt;

&lt;p&gt;1.Clip.antiAlias&lt;/p&gt;

&lt;p&gt;2.Clip.antiAliasWithSaveLayer&lt;/p&gt;

&lt;p&gt;3.Clip.hardEdge&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ScrollBehavior&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Scroll behavior is used to define the scroll behavior when the page view is at the start or bottom. As you can see in android we see a glowing light when we are at the end of the list.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;padEnds&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Whether to add padding to both ends of the list.&lt;/p&gt;

&lt;p&gt;If this is set to true and [PageController.viewportFraction] &amp;lt; 1.0, padding will be added such that the first and last child slivers will be in the center of the viewport when scrolled all the way to the start or end, respectively.&lt;/p&gt;

&lt;p&gt;If [PageController.viewportFraction] &amp;gt;= 1.0, this property has no effect.&lt;/p&gt;

&lt;p&gt;This property defaults to true and must not be null.&lt;/p&gt;

&lt;h2&gt;
  
  
  Instagram Reels clone
&lt;/h2&gt;

&lt;p&gt;we will make a reels screen clone only the UI part and instead of video, we will use here images to make it less complex.&lt;/p&gt;

&lt;p&gt;First, we want to add the widget on top of the page so we need to use a stack.&lt;/p&gt;

&lt;p&gt;First, let's create the bottom user name and description of the reels screen.&lt;br&gt;
For this, we will use a Row to add a user image and name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Row(
      children: const [
        CircleAvatar(
          backgroundColor: Colors.blue,
          radius: 20,
        ),
        SizedBox(
          width: 20,
        ),
        Text(
          "Name of user",
          style: TextStyle(color: Colors.white),
        ),
      ],
    );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6k7ukrn7o92bmbp28tls.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6k7ukrn7o92bmbp28tls.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Then we will add this row into a column that contains the description of the video and also add some padding to it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Padding(
      padding: const EdgeInsets.all(8.0),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            mainAxisSize: MainAxisSize.min,
            children: const [
              CircleAvatar(
                backgroundColor: Colors.blue,
                radius: 20,
              ),
              SizedBox(
                width: 20,
              ),
              Text(
                "Name of user",
                style: TextStyle(color: Colors.white),
              ),
            ],
          ),
          const Text(
                "This is the very long description of the videos which has many lines This is the very long description of the videos which has many lines This is the very long description of the videos which has many lines This is the very long description of the videos which has many lines",
overflow: TextOverflow.ellipsis,
            softWrap: true,
            maxLines: 2,
            style: TextStyle(color: Colors.white),
          ),
        ],
      ),
    );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1t5wp4prua8r1xu7akql.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1t5wp4prua8r1xu7akql.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Now you can see a render overflow error, this is because the text of the description does not have a horizontal bound.&lt;/p&gt;

&lt;p&gt;Before solving this let's add the buttons of like and share on the right side. Just add the new button column and add the previous column in a row. Here I am not using the exact buttons icons that are used in reels.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Buttons extends StatelessWidget {
  const Buttons({Key? key}) : super(key: key);
@override
  Widget build(BuildContext context) {
    return Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        IconButton(
            onPressed: () {},
            icon: const Icon(
              Icons.heart_broken_outlined,
              color: Colors.white,
            )),
        IconButton(
            onPressed: () {},
            icon: const Icon(
              Icons.message_outlined,
              color: Colors.white,
            )),
        IconButton(
            onPressed: () {},
            icon: const Icon(
              Icons.share,
              color: Colors.white,
            )),
      ],
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add this to the previous row. Now if we remove the description text for some time our UI will look like this.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F89ktnmsm63ptoluigubl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F89ktnmsm63ptoluigubl.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Now bring back the description and wrap both the child of row into flex and give it the ratio of 8 and 1.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now the overall code looks like this.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class SinglePage extends StatelessWidget {
  const SinglePage({Key? key}) : super(key: key);
@override
  Widget build(BuildContext context) {
    return Stack(children: [
      Container(color: Colors.red),
      Align(
        alignment: Alignment.bottomLeft,
        child: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Flexible(
                flex: 8,
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Row(
                      mainAxisSize: MainAxisSize.min,
                      children: const [
                        CircleAvatar(
                          backgroundColor: Colors.blue,
                          radius: 20,
                        ),
                        SizedBox(
                          width: 20,
                        ),
                        Text(
                          "Name of user",
                          style: TextStyle(color: Colors.white),
                        ),
                      ],
                    ),
                    const Text(
                      "This is the very long description of the videos which has many lines This is the very long description of the videos which has many lines This is the very long description of the videos which has many lines This is the very long description of the videos which has many lines",
                      overflow: TextOverflow.ellipsis,
                      softWrap: true,
                      maxLines: 2,
                      style: TextStyle(color: Colors.white),
                    ),
                  ],
                ),
              ),
              const Flexible(flex: 1, child: Buttons())
            ],
          ),
        ),
      )
    ]);
  }
}
class Buttons extends StatelessWidget {
  const Buttons({Key? key}) : super(key: key);
@override
  Widget build(BuildContext context) {
    return Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        IconButton(
            onPressed: () {},
            icon: const Icon(
              Icons.heart_broken_outlined,
              color: Colors.white,
            )),
        IconButton(
            onPressed: () {},
            icon: const Icon(
              Icons.message_outlined,
              color: Colors.white,
            )),
        IconButton(
            onPressed: () {},
            icon: const Icon(
              Icons.share,
              color: Colors.white,
            )),
      ],
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;And the UI looks like this.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdsixlh6kmp548gmfnr1j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdsixlh6kmp548gmfnr1j.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now just we have to add this single page into page view and give random colors to the background.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final code&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
class HomeScreen extends StatelessWidget {
  HomeScreen({Key? key}) : super(key: key);
  final controller = PageController();
  @override
  Widget build(BuildContext context) {
    return PageView(
      controller: controller,
      scrollDirection: Axis.vertical,
      padEnds: false,
      children: const [
        SinglePage(
          color: Colors.red,
        ),
        SinglePage(
          color: Colors.green,
        ),
        SinglePage(
          color: Colors.yellow,
        ),
        SinglePage(color: Colors.amber),
        SinglePage(
          color: Colors.purple,
        ),
      ],
    );
  }
}
class SinglePage extends StatelessWidget {
  const SinglePage({
    Key? key,
    required this.color,
  }) : super(key: key);
  final Color color;
  @override
  Widget build(BuildContext context) {
    return Stack(children: [
      Container(color: color),
      Align(
        alignment: Alignment.bottomLeft,
        child: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Flexible(
                flex: 8,
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Row(
                      mainAxisSize: MainAxisSize.min,
                      children: const [
                        CircleAvatar(
                          backgroundColor: Colors.blue,
                          radius: 20,
                        ),
                        SizedBox(
                          width: 20,
                        ),
                        Text(
                          "Name of user",
                          style: TextStyle(color: Colors.white),
                        ),
                      ],
                    ),
                    const Text(
                      "This is the very long description of the videos which has many lines This is the very long description of the videos which has many lines This is the very long description of the videos which has many lines This is the very long description of the videos which has many lines",
                      overflow: TextOverflow.ellipsis,
                      softWrap: true,
                      maxLines: 2,
                      style: TextStyle(color: Colors.white),
                    ),
                  ],
                ),
              ),
              const Flexible(flex: 1, child: Buttons())
            ],
          ),
        ),
      )
    ]);
  }
}
class Buttons extends StatelessWidget {
  const Buttons({Key? key}) : super(key: key);
@override
  Widget build(BuildContext context) {
    return Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        IconButton(
            onPressed: () {},
            icon: const Icon(
              Icons.heart_broken_outlined,
              color: Colors.white,
            )),
        IconButton(
            onPressed: () {},
            icon: const Icon(
              Icons.message_outlined,
              color: Colors.white,
            )),
        IconButton(
            onPressed: () {},
            icon: const Icon(
              Icons.share,
              color: Colors.white,
            )),
      ],
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Final UI&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F750%2F1%2AYUkLGy_PNW_y2D04GeTauw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F750%2F1%2AYUkLGy_PNW_y2D04GeTauw.gif" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>android</category>
      <category>develop</category>
      <category>ios</category>
    </item>
    <item>
      <title>Dismissible widget: Slide to delete in Flutter</title>
      <dc:creator>Aakashp</dc:creator>
      <pubDate>Thu, 24 Mar 2022 17:58:08 +0000</pubDate>
      <link>https://dev.to/aakashp/dismissible-widget-slide-to-delete-in-flutter-hnf</link>
      <guid>https://dev.to/aakashp/dismissible-widget-slide-to-delete-in-flutter-hnf</guid>
      <description>&lt;p&gt;Hello, readers welcome back to another article. Hope you all are doing great. So in this article, we will see how we can delete any item from a list view just like in the Gmail app.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uS7dgeRO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ni79pwbd3ujnuma974qd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uS7dgeRO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ni79pwbd3ujnuma974qd.png" alt="sample image" width="880" height="586"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First, let's quickly create a list view with 10 items. Now to make the list items delete on sliding left or right just wrap them in a widget called Dismissible. And there is onDismissed function which is called when the item is removed from the list. write your logic to delete the data from a database or local storage on items deleted from the list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Constructor of Dismissible
Dismissible({
  required Key key,
  required Widget child,
  Widget? background,
  Widget? secondaryBackground,
  Future&amp;lt;bool?&amp;gt; Function(DismissDirection)? confirmDismiss,
  void Function()? onResize,
  void Function(DismissUpdateDetails)? onUpdate,
  void Function(DismissDirection)? onDismissed,
  DismissDirection direction = DismissDirection.horizontal,
  Duration? resizeDuration = const Duration(milliseconds: 300),
  Map&amp;lt;DismissDirection, double&amp;gt; dismissThresholds = const &amp;lt;DismissDirection, double&amp;gt;{},
  Duration movementDuration = const Duration(milliseconds: 200),
  double crossAxisEndOffset = 0.0,
  DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  HitTestBehavior behavior = HitTestBehavior.opaque,
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's see what more we can do with this widget. Let us explore each attribute of the dismissible widget one by one. In the dismissible widget, the &lt;strong&gt;key&lt;/strong&gt;is the required attribute because it uses a key of each item in the list to manage and update the UI after any item is dismissed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Child&lt;/strong&gt;: You can guess from the name this is the child widget of this widget.&lt;/p&gt;

&lt;h3&gt;
  
  
  Background and Secondary background
&lt;/h3&gt;

&lt;p&gt;The background is the widget that will be seen when the list item is being dismissed. For example, if you want to delete the data then you can show a container with red color like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Dismissible(
            key: Key(index.toString()),
            background: Container(color: Colors.red),
            onDismissed: (direction) {},
            child: Card(
              child: ListTile(
                title: Text("this is $index item"),
              ),
            ),
          );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XVJyO7Gv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5detrwnkstzl5m0f2uau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XVJyO7Gv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5detrwnkstzl5m0f2uau.png" alt="sample image" width="600" height="750"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Similarly, the secondary background is the other background that will be shown on the item being dismissed. If you dismiss the item to the right then you can see the background but when you dismiss the item to left you can see the secondary background. For secondary background to work background should not be null.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rjtiDPus--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d3p9750fw9p4tipxcu17.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rjtiDPus--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d3p9750fw9p4tipxcu17.png" alt="sample image" width="600" height="750"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And to make it look more beautiful you can also add an icon to the container like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;background: Container(
              color: Colors.red,
              padding: const EdgeInsets.symmetric(horizontal: 20),
              child: const Icon(
                Icons.delete,
                color: Colors.white,
              ),
              alignment: Alignment.centerLeft,
            ),
secondaryBackground: Container(
              color: Colors.green,
              padding: const EdgeInsets.symmetric(horizontal: 20),
              child: const Icon(
                Icons.archive,
                color: Colors.white,
              ),
              alignment: Alignment.centerRight,
            ),
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UVtKRRg0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/54wwnipksqcd7d9bhryf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UVtKRRg0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/54wwnipksqcd7d9bhryf.png" alt="sample image" width="600" height="750"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  direction
&lt;/h3&gt;

&lt;p&gt;Direction is the direction in which you want the widget to be dismissed. Horizontal or vertical.&lt;/p&gt;

&lt;h3&gt;
  
  
  ondismissed
&lt;/h3&gt;

&lt;p&gt;This function is called when you dismiss any item from the list. You can use this function to modify the data. For example, if the user removed any item from the list then you can delete that from the database in this function. This function has one parameter of direction which tells in which direction the user had dismissed the item based on that you can perform the actions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;onDismissed: (direction) {
              if (direction == DismissDirection.startToEnd) {
                print("Item deleted");
                //your code to delete item from database or local storage
              } else if (direction == DismissDirection.endToStart) {
                print("item archived");
                //your code to move item to archive
              }
            },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  confirmdismis
&lt;/h3&gt;

&lt;p&gt;Confirm dismiss is the function that will be called when the item is dismissed. It is used to confirm the action. This function also has dismissed direction parameter to check in which direction the user had dismissed the widget. For example, we can check if the direction right then shows a dialog to the user to delete an item, and if the direction is left then show a dialog to archive the item like in the Gmail app.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;confirmDismiss: (direction) async {
              if (direction == DismissDirection.startToEnd) {
                bool dismiss = false;
                await showDialog(
                    context: context,
                    builder: (context) {
                      return AlertDialog(
                        title: const Text("Are you sure you want to delete the item"),
                        actions: [
                          TextButton(
                              onPressed: () {
                                dismiss = true;
                                Navigator.pop(context);
                              },
                              child: const Text("Yes")),
                          TextButton(
                              onPressed: () {
                                dismiss = false;
                                Navigator.pop(context);
                              },
                              child: const Text("No")),
                        ],
                      );
                    });
                return dismiss;
              } else if (direction == DismissDirection.endToStart) {
                //similar for archiving item
                //show dailog to confirm archive item on sliding on left side
              }
            },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;DismissDirection.startToEnd&lt;/strong&gt; is from right side to left side &lt;strong&gt;and DismissDirection.endToStart&lt;/strong&gt; is from left side to right side dismiss.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NL1WT-Rf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sp1ayyk7g8h5kv5bf8ae.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NL1WT-Rf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sp1ayyk7g8h5kv5bf8ae.png" alt="sample image" width="600" height="750"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  onresize and resizeduration
&lt;/h3&gt;

&lt;p&gt;So when you dismiss the widget the item size that you had dismissed is reduced slowly. Resize duration is the duration in which the item should be removed from the list after dismissal. and onresize function is called when the item is being shrunk.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Dismissible(
            key: Key(index.toString()),
            background: Container(
              color: Colors.red,
              padding: const EdgeInsets.symmetric(horizontal: 20),
              child: const Icon(
                Icons.delete,
                color: Colors.white,
              ),
              alignment: Alignment.centerLeft,
            ),
            secondaryBackground: Container(
              color: Colors.green,
              padding: const EdgeInsets.symmetric(horizontal: 20),
              child: const Icon(
                Icons.archive,
                color: Colors.white,
              ),
              alignment: Alignment.centerRight,
            ),
            onResize: () {
              print("resized");
            },
            resizeDuration: Duration(seconds: 5),
            child: Card(
              child: ListTile(
                title: Text("this is $index item"),
              ),
            ),
          );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0CQ7RLKr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/luoq86v2o8cwfxmoyf1l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0CQ7RLKr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/luoq86v2o8cwfxmoyf1l.png" alt="sample image" width="600" height="750"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By default, the resize duration is 300 milliseconds. And if you give null in resize duration then onresize function will not be called and items will not be shrunk from the list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;onResize: () {
              print("resized");
            },
resizeDuration: null,
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--r6Z1_z1P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c0knd6av5cjad3bli29r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--r6Z1_z1P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c0knd6av5cjad3bli29r.png" alt="sample image" width="600" height="750"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  onupdate
&lt;/h3&gt;

&lt;p&gt;on update is a function that is called every time when you drag the widget. it has a parameter called details which give details like direction, previous reached and currently reached state of drage.&lt;/p&gt;

&lt;p&gt;previous reached and reached are boolean value which tells if the drag has passed the threshold for an item to be dismissed or not. Like when you drag the item and if it reached center(assuming) then the current state will be true and the previous state will be false. You can understand better from the image below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WbBwZ6ZO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yuhru55e86xdfun7ouxi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WbBwZ6ZO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yuhru55e86xdfun7ouxi.png" alt="sample image" width="880" height="1399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  dismiss thresholds
&lt;/h3&gt;

&lt;p&gt;As seen in the above image we can give the threshold at which the user leaves the hand and the item will be dismissed. DismissTreshold is a MAP of threshold for each dismiss direction. You can give different thresholds for different directions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dismissThresholds: {
              DismissDirection.startToEnd: 0.5,
              DismissDirection.endToStart: 0.1
            },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  movementDuration
&lt;/h3&gt;

&lt;p&gt;This is the duration the widget takes to slide away from the screen.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Dismissible(
            key: Key(index.toString()),
            background: Container(
              color: Colors.red,
              padding: const EdgeInsets.symmetric(horizontal: 20),
              child: const Icon(
                Icons.delete,
                color: Colors.white,
              ),
              alignment: Alignment.centerLeft,
            ),
            secondaryBackground: Container(
              color: Colors.green,
              padding: const EdgeInsets.symmetric(horizontal: 20),
              child: const Icon(
                Icons.archive,
                color: Colors.white,
              ),
              alignment: Alignment.centerRight,
            ),
            movementDuration: Duration(seconds: 10),
            child: Card(
              child: ListTile(
                title: Text("this is $index item"),
              ),
            ),
          );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2aOUgGxt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gxq03q5tijt67u508gtp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2aOUgGxt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gxq03q5tijt67u508gtp.png" alt="sample image" width="600" height="750"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  crossAxisEndOffset
&lt;/h3&gt;

&lt;p&gt;This value defines the offset the widget should move in cross-axis while being dismissed. If dismissal direction is horizontal and the value of offset is positive it moves downward and if negative it moves upward.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dJBlU3nD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ohql1vkz8a5wtucp0rcl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dJBlU3nD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ohql1vkz8a5wtucp0rcl.png" alt="sample image" width="600" height="750"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bQ_l_e3N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e6y8acl0jony2aenmj9b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bQ_l_e3N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e6y8acl0jony2aenmj9b.png" alt="sample image" width="600" height="750"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  dragStartBehavior(from documentation)
&lt;/h3&gt;

&lt;p&gt;Determines the way that drag start behavior is handled.&lt;/p&gt;

&lt;p&gt;If set to [DragStartBehavior.start], the drag gesture used to dismiss a dismissible will begin at the position where the drag gesture won the arena. If set to [DragStartBehavior.down] it will begin at the position where a down event is first detected.&lt;br&gt;
In general, setting this to [DragStartBehavior.start] will make drag animation smoother, and setting it to [DragStartBehavior.down] will make drag behavior feel slightly more reactive.&lt;br&gt;
By default, the drag start behavior is [DragStartBehavior.start].&lt;/p&gt;

&lt;h3&gt;
  
  
  behavior
&lt;/h3&gt;

&lt;p&gt;How to behave during hit tests.This defaults to [HitTestBehavior.opaque].&lt;/p&gt;

&lt;p&gt;This definition is from the documentation and I have no idea about what it is, if you know what is hit test behavior please let me know.&lt;/p&gt;

&lt;p&gt;If you want to add more options like multiple actions on sliding the item then you can use this plugin also.&lt;br&gt;
&lt;a href="https://pub.dev/packages/flutter_slidable"&gt;flutter_slidable&lt;/a&gt;&lt;br&gt;
If you liked this article then you can follow me for more stuff like this and if you don't like anything then also feel free to tell me.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>android</category>
      <category>ios</category>
      <category>application</category>
    </item>
    <item>
      <title>Why column wrapped inside the center is not centered vertically in flutter?</title>
      <dc:creator>Aakashp</dc:creator>
      <pubDate>Fri, 11 Mar 2022 11:10:56 +0000</pubDate>
      <link>https://dev.to/aakashp/why-column-wrapped-inside-the-center-is-not-centered-vertically-in-flutter-6nc</link>
      <guid>https://dev.to/aakashp/why-column-wrapped-inside-the-center-is-not-centered-vertically-in-flutter-6nc</guid>
      <description>&lt;p&gt;Hello readers, welcome back to another article. If you are a beginner flutter developer and making apps with flutter then you may probably have already used the column and row widgets. You may also have got into a situation where you want to center the column or row widget.&lt;/p&gt;

&lt;p&gt;So whenever you center a column or a row by wrapping it inside the center widget then you may have seen that the column widget is not centered vertically it is only centered horizontally.&lt;/p&gt;

&lt;p&gt;Similarly, with the row widget, it is not centered horizontally it’s only centered vertically so why is this happening what is the reason that the column and row wrapped inside the center are not showing on the center of the screen. so in this article, we will see an attribute of both column and the row responsible for this behavior.&lt;br&gt;
Let's first try to see how another widget behaves when we add it into the center widget’s child. We are wrapping a button inside the center.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Center(
      child: ElevatedButton(
        onPressed: () {},
        child: const Text("Button"),
      ),
    );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And here we can see the button is centered both horizontally and vertically.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5yotQwMj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4dg8fy594wgnexsoeepe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5yotQwMj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4dg8fy594wgnexsoeepe.png" alt="Button wrapped in center" width="875" height="1464"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let's try the same with the column. As you can see below in the image there are three buttons in the column and the column is only centered horizontally and not vertically. Similarly, the row is only centered vertically not horizontally.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Center(
        child:Column(
          children: [
            ElevatedButton(
              onPressed: () {},
              child: const Text("Button"),
            ),
            ElevatedButton(
              onPressed: () {},
              child: const Text("Button"),
            ),
            ElevatedButton(
              onPressed: () {},
              child: const Text("Button"),),]),),
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bn8u4hhs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jixscpn9kij14b2hqfq7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bn8u4hhs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jixscpn9kij14b2hqfq7.png" alt="column and row in center" width="875" height="867"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So what's wrong here? Why is this happening? Here the problem is the size of both widgets. To understand better let's wrap the column inside the container and give it a background color to see how much space it's taking.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Center(
        child: Container(
          color:Colors.red,
          child: Column(
            children: [
              ElevatedButton(
                onPressed: () {},
                child: const Text("Button"),
              ),
              ElevatedButton(
                onPressed: () {},
                child: const Text("Button"),
              ),
              ElevatedButton(
                onPressed: () {},
                child: const Text("Button"),
              ),],),),),
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5srx_tbn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0o9q1ukyoyqave2tuefb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5srx_tbn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0o9q1ukyoyqave2tuefb.png" alt="column and row in center with color" width="875" height="867"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here you can see the space covered in red color is the space taken by the column. So why the column is taking full-height space? Because when you see at the constructor of column widget there is an attribute called mainAxisSize. And for the column, the main axis is vertical, and by the default value of mainAxisSize is set to MAX. so if we change mainAxisSize to min our problem is solved.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Center(
        child: Container(
          color:Colors.red,
          child: Column(
            mainAxisSize:MainAxisSize.min,
            children: [
              ElevatedButton(
                onPressed: () {},
                child: const Text("Button"),
              ),
              ElevatedButton(
                onPressed: () {},
                child: const Text("Button"),
              ),
              ElevatedButton(
                onPressed: () {},
                child: const Text("Button"),
              ),
            ],
          ),
        ),
      ),
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FJ_-12eN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/utfig2a6gn5nu8lz0h5n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FJ_-12eN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/utfig2a6gn5nu8lz0h5n.png" alt="output" width="875" height="867"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Now you can see the column is taking only as much space as it required. Similarly happens with the row but the difference is the main axis of the row is horizontal so it takes space horizontally.&lt;br&gt;
And that's all in this article if you want to get more article like this then you can follow me&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>android</category>
    </item>
    <item>
      <title>How to return data from the screen in flutter</title>
      <dc:creator>Aakashp</dc:creator>
      <pubDate>Fri, 25 Feb 2022 13:52:12 +0000</pubDate>
      <link>https://dev.to/aakashp/how-to-return-data-from-the-screen-in-flutter-4b60</link>
      <guid>https://dev.to/aakashp/how-to-return-data-from-the-screen-in-flutter-4b60</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnyi70dc3v1yjfu9ptqoe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnyi70dc3v1yjfu9ptqoe.png" alt="Cover image"&gt;&lt;/a&gt;&lt;br&gt;
Hello, readers welcome back again to another blog. In the previous blog, we have seen how to pass the data from the first screen to the second screen but sometimes we also need to pass the data from the second screen to the first screen. So today we will see how we can do that in flutter.&lt;/p&gt;

&lt;p&gt;Before starting if you had not seen the previous pard I will recommend first reading that.&lt;/p&gt;

&lt;p&gt;In the previous article we saw that to push a screen we use Navigator.push() function. But when you will see the return type of the function it returns Futture where T is generic, which means we can put any object in place of T.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Future&amp;lt;T?&amp;gt; push&amp;lt;T extends Object?&amp;gt;(BuildContext context, Route&amp;lt;T&amp;gt; route)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here T is the type of data that we are expecting to return from the screen.&lt;/p&gt;

&lt;p&gt;As this returns a future we now need to put await to stop and wait until the second screen is poped and we get our data.&lt;/p&gt;

&lt;p&gt;Now in the second screen, we can pop the screen using the function Navigator.pop(). Similarly in this function also there is a generic type T which tells the type of data we want to return. And this function has an optional field of type T, the data we want to return.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void pop&amp;lt;T extends Object?&amp;gt;(BuildContext context, [T? result])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Let's understand this with an example
&lt;/h2&gt;

&lt;p&gt;We will create a button on the first screen which on pressing the user will go to the second screen.&lt;/p&gt;

&lt;p&gt;On the second screen, we will give the user three buttons to press. When the user presses any one of the buttons we will pop the screen and return the String data to the first screen with the message “user clicked the x button”.&lt;/p&gt;

&lt;p&gt;And we will also check if the data is null or not on the first screen because the user may not click on any button and press the back button in this case the data returned by the second screen will be null.&lt;/p&gt;

&lt;h3&gt;
  
  
  First Screen
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class FirstScreen extends StatelessWidget {
  const FirstScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          ElevatedButton(
              onPressed: () async {
                String? result = await Navigator.push&amp;lt;String&amp;gt;(context,
                    MaterialPageRoute(builder: (context) {
                  return const SecondScreen();
                }));

                ScaffoldMessenger.of(context).showSnackBar(SnackBar(
                    content: Text(result ?? "User doesn't press anything")));
              },
              child: const Text("Next Screen"))
        ],
      ),
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Second Screen
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class SecondScreen extends StatelessWidget {
  const SecondScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
          child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          ElevatedButton(
              onPressed: () {
                Navigator.pop&amp;lt;String&amp;gt;(context, "User pressed Button 1");
              },
              child: const Text("Button 1")),
          ElevatedButton(
              onPressed: () {
                Navigator.pop&amp;lt;String&amp;gt;(context, "User pressed Button 2");
              },
              child: const Text("Button 2")),
          ElevatedButton(
              onPressed: () {
                Navigator.pop&amp;lt;String&amp;gt;(context, "User pressed Button 3");
              },
              child: const Text("Button 3"))
        ],
      )),
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Output
&lt;/h3&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/8Gg5Zu0sTpc"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to pass data across the screen in a flutter app.</title>
      <dc:creator>Aakashp</dc:creator>
      <pubDate>Tue, 01 Feb 2022 06:19:16 +0000</pubDate>
      <link>https://dev.to/aakashp/how-to-pass-data-across-the-screen-in-a-flutter-app-2fhg</link>
      <guid>https://dev.to/aakashp/how-to-pass-data-across-the-screen-in-a-flutter-app-2fhg</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Jhep4MHs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/swvanjqdmsf2ug5tutp8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Jhep4MHs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/swvanjqdmsf2ug5tutp8.png" alt="Cover Image" width="875" height="1093"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hello readers, welcome again to another blog. So recently I was creating a flutter app and I need to pass the data from one screen to another screen. And if you are also a beginner in flutter development then you may also need to know how to pass data from one screen to other. When I searched, I got two ways of passing data from one screen to the other in flutter. Let's see both of them one by one.&lt;/p&gt;

&lt;p&gt;Before that, we need to create a situation in which we send data from one screen to another. let's say we have a textbox on one screen which takes the name of the user and the user press on login. After which the user will be directed to the next screen in which the “Welcome username” message will be displayed.&lt;/p&gt;

&lt;p&gt;In this, we will first take the name of the user on the first screen and then pass the name on the second screen to show the welcome message.&lt;/p&gt;

&lt;p&gt;Two ways I know of passing data are :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Passing in the constructor of the new class&lt;/li&gt;
&lt;li&gt;Passing in route settings&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Passing in constructor
&lt;/h2&gt;

&lt;p&gt;Let's see how we can use the constructor of the second screen to pass the name of the user from the first screen.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class FirstScreen extends StatelessWidget {
  const FirstScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Center(
      child: SizedBox(
        width: 300,
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            const TextField(
                decoration: InputDecoration(
              hintText: "Enter your Name",
              labelText: "Name",
              border: OutlineInputBorder(),
            )),
            const SizedBox(
              height: 20,
            ),
            ElevatedButton(onPressed: () {}, child: const Text("Login"))
          ],
        ),
      ),
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the code for the FirstScreen class. There is just a Column widget that has a TextField to take the input from the user and an ElevatedButton to go to the next screen.&lt;/p&gt;

&lt;p&gt;Now let's see the code of the second screen class. Below in the constructor, we have a String field called name which we will use to pass the value from the first screen to the second screen on button press.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class SecondScreen extends StatelessWidget {
   const SecondScreen(this.name, {Key? key}) : super(key: key);
  final String name;
  @override
  Widget build(BuildContext context) {
    return Container();
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's create a text editing controller to read the value of the text field and also set the onPressed function of the login button. And also display a text widget on the second screen. And at last, the whole code will look like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class FirstScreen extends StatelessWidget {
  FirstScreen({Key? key}) : super(key: key);
final TextEditingController controller = TextEditingController();
  @override
  Widget build(BuildContext context) {
    return Center(
      child: SizedBox(
        width: 300,
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            TextField(
                controller: controller,
                decoration: const InputDecoration(
                  hintText: "Enter your Name",
                  labelText: "Name",
                  border: OutlineInputBorder(),
                )),
            const SizedBox(
              height: 20,
            ),
            ElevatedButton(
                onPressed: () {
                  String name = controller.text;
         Navigator.push(context, MaterialPageRoute(
         builder: (context) =&amp;gt; SecondScreen(name)));
                },
                child: const Text("Login"))
          ],
        ),
      ),
    );
  }
}

class SecondScreen extends StatelessWidget {
  const SecondScreen(this.name, {Key? key}) : super(key: key);
final String name;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Text("Welcome $name"),
      ),
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want you can also make the name field in the second screen optional argument by putting it inside the square bracket and showing some default value if the name is NULL.&lt;/p&gt;

&lt;h3&gt;
  
  
  Output:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AJPA-Ons--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rj098n5pe5fyk6qaecbd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AJPA-Ons--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rj098n5pe5fyk6qaecbd.png" alt="Output GIF image" width="600" height="769"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Passing in Route settings
&lt;/h2&gt;

&lt;p&gt;Now that you have seen how to pass data with the help of a constructor it is similar to passing the data from route but the only difference is we can pass any type of data from route settings. Let's see this with an example.&lt;/p&gt;

&lt;p&gt;When we push a screen with Navigator.push we give it a page route. And inside that route, we can also pass data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Navigator.push(context, MaterialPageRoute(
                        builder: (context) =&amp;gt; SecondScreen(name),
                        settings: RouteSettings(arguments: name)));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;here we have passed the name inside the arguments of RouteSettings.&lt;/p&gt;

&lt;p&gt;And to get the data on the second screen we use modelroute. You will get the data as the Object? so you need to cast it to what data type you have sent from the first screen.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String name = ModalRoute.of(context)!.settings.arguments as String;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At last the overall code with route setting will look like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class FirstScreen extends StatelessWidget {
  FirstScreen({Key? key}) : super(key: key);
final TextEditingController controller = TextEditingController();
  @override
  Widget build(BuildContext context) {
    return Center(
      child: SizedBox(
        width: 300,
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            TextField(
                controller: controller,
                decoration: const InputDecoration(
                  hintText: "Enter your Name",
                  labelText: "Name",
                  border: OutlineInputBorder(),
                )),
            const SizedBox(
              height: 20,
            ),
            ElevatedButton(
                onPressed: () {
                  String name = controller.text;
                      Navigator.push(context,
                      MaterialPageRoute(
                      builder: (context) =&amp;gt; const SecondScreen(),
                      settings: RouteSettings(arguments: name)));
                },
                child: const Text("Login"))
          ],
        ),
      ),
    );
  }
}
class SecondScreen extends StatelessWidget {
  const SecondScreen({Key? key}) : super(key: key);
@override
  Widget build(BuildContext context) {
    String name = ModalRoute.of(context)!.settings.arguments as String;
    return Scaffold(
      body: Center(
        child: Text("Welcone $name"),
      ),
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reference: &lt;a href="https://docs.flutter.dev/cookbook/navigation/passing-data"&gt;https://docs.flutter.dev/cookbook/navigation/passing-data&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to show progress indicator while loading Image.network() in Flutter</title>
      <dc:creator>Aakashp</dc:creator>
      <pubDate>Sun, 23 Jan 2022 15:55:37 +0000</pubDate>
      <link>https://dev.to/aakashp/how-to-show-progress-indicator-while-loading-imagenetwork-in-flutter-1gle</link>
      <guid>https://dev.to/aakashp/how-to-show-progress-indicator-while-loading-imagenetwork-in-flutter-1gle</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ehR4c7XN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/navbpezj4mfd7qyfla21.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ehR4c7XN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/navbpezj4mfd7qyfla21.png" alt="cover image" width="880" height="495"&gt;&lt;/a&gt; &lt;br&gt;
Hello readers, Recently Flutter is in trend and many users may be developing apps in flutter. And one of the basic widget in flutter is Image which is used almost in all app. So let's first see what is this Image Widget.&lt;/p&gt;

&lt;p&gt;Image as you can guess by the name is used to show the image. Now this widget has 4 named constructors Image.assets(), Image.file(), Image.network(), Image.memory().&lt;/p&gt;

&lt;p&gt;If you are a Flutter developer then you may already know what all these types do and what their use is. We will discuss Image. network().&lt;/p&gt;

&lt;p&gt;Image.network() is used to show an image from the internet. You give this widget a URL and it will do all the magic of downloading and showing an image on the screen. Below is the constructor of the Image.network(). As you can see the first argument is src which is the URL of the image file. Other than that there are many other arguments but we will only focus on two frameBuilder, loadingBuilder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Image Image.network(
  String src, {
  Key? key,
  double scale = 1.0,
  Widget Function(BuildContext, Widget, int?, bool)? frameBuilder,
  Widget Function(BuildContext, Widget, ImageChunkEvent?)? loadingBuilder,
  Widget Function(BuildContext, Object, StackTrace?)? errorBuilder,
  String? semanticLabel,
  bool excludeFromSemantics = false,
  double? width,
  double? height,
  Color? color,
  Animation&amp;lt;double&amp;gt;? opacity,
  BlendMode? colorBlendMode,
  BoxFit? fit,
  AlignmentGeometry alignment = Alignment.center,
  ImageRepeat repeat = ImageRepeat.noRepeat,
  Rect? centerSlice,
  bool matchTextDirection = false,
  bool gaplessPlayback = false,
  FilterQuality filterQuality = FilterQuality.low,
  bool isAntiAlias = false,
  Map&amp;lt;String, String&amp;gt;? headers,
  int? cacheWidth,
  int? cacheHeight,
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Frame Builder and Loading Builder are the two optional function arguments. Let's see each of them and why are they used.&lt;/p&gt;

&lt;p&gt;loadingBuilder: It is called while the image is being downloaded. Below is the description of loadingBuilder from the flutter docs.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A builder that specifies the widget to display to the user while an image is still loading.&lt;br&gt;
If this is null, and the image is loaded incrementally (e.g. over a network), the user will receive no indication of the progress as the bytes of the image are loaded.&lt;br&gt;
For more information on how to interpret the arguments that are passed to this builder, see the documentation on [ImageLoadingBuilder].&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;frameBuilder: Below is the description of frameBuilder from the Flutter docs.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A builder function responsible for creating the widget that represents this image.&lt;br&gt;
If this is null, this widget will display an image that is painted as soon as the first image frame is available (and will appear to "pop" in if it becomes available asynchronously). Callers might use this builder to add effects to the image (such as fading the image in when it becomes available) or to display a placeholder widget while the image is loading.&lt;br&gt;
To have finer-grained control over the way that an image's loading progress is communicated to the user, see [loadingBuilder].&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In short, this function is called when the first frame of the image is built. This function deals with how to build the frames of an image.&lt;/p&gt;

&lt;p&gt;Ok, now lots of theory let us see this in practice.&lt;br&gt;
First, let's see how we use Image.network() usually.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Image.network(
        "https://images.unsplash.com/photo-1526666923127- b2970f64b422?q=1080&amp;amp;h=720")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We just give the URL of the image in its constructor. But the output of this may look like this. Suddenly the image appears when it got downloaded.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/_6enHAsKAnE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Now we will use loadingBuilder and frameBuilder to show circular progress indicator while the image is loading.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Center(
child: Image.network(
"https://images.unsplash.com/photo-1526666923127-b2970f64b422",
frameBuilder: (context, child, frame, wasSynchronouslyLoaded) {
return child;
},
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress == null) {
return child;
} else {
return Center(
child: CircularProgressIndicator(),
);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While the image is being downloaded it will show the widget from the loading builder and when the download is completed it will show the widget from the frame builder.&lt;/p&gt;

&lt;p&gt;In the loading builder, we are first checking if the progress is null or not. If it is null we directly return the child else we show the circular progress indicator. We can also show progress value by using the data from loadingProgress.&lt;/p&gt;

&lt;p&gt;And after that frame builder will return the child which contains the actual image. You can also wrap the child inside some animation to make it look good.&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/QQ6LM3LjxPk"&gt;
&lt;/iframe&gt;
&lt;br&gt;
You can also show loading by using a placeholder gif image or using the stack as shown &lt;a href="https://docs.flutter.dev/cookbook/images/fading-in-images"&gt;here&lt;/a&gt;.&lt;br&gt;
NOTE: There may be another method to achieve the same thing effectively, if you find anything wrong or better than this please let me know.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>image</category>
    </item>
    <item>
      <title>Host your WordPress site for free.</title>
      <dc:creator>Aakashp</dc:creator>
      <pubDate>Sat, 08 Jan 2022 14:57:01 +0000</pubDate>
      <link>https://dev.to/aakashp/host-your-wordpress-site-for-free-1j9e</link>
      <guid>https://dev.to/aakashp/host-your-wordpress-site-for-free-1j9e</guid>
      <description>&lt;p&gt;Hello readers,&lt;br&gt;
Today most personal blog websites or Informative websites are running on WordPress. Even I was also using WordPress for my blog site. As WordPress requires a server we need to host the website on our machine or we can rent from providers like AWS and Google Cloud.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7UwVZgSO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4zpkqtl5b125k1euoj7b.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7UwVZgSO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4zpkqtl5b125k1euoj7b.jpg" alt="Blog" width="880" height="583"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But as a fresh Blog Site, I don't think you need any computational power to just show a page to the user which contains just text and images. So today, I will show how you can host your WordPress site for free on Google's Firebase Hosting. And at last, I will also be talking about some Disadvantages of this.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do we need to do this?
&lt;/h2&gt;

&lt;p&gt;First, let's talk about why are we doing this. Why do we need to convert our WordPress site to HTML?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WvY3-A-9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4vyu5qqwe711vv5lv3nh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WvY3-A-9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4vyu5qqwe711vv5lv3nh.png" alt="Money" width="875" height="583"&gt;&lt;/a&gt;&lt;br&gt;
One reason is it's free, We can host our site for free on Firebase without any monthly charges. I know nowadays clouds are very cheap but why to pay when you can get them for free. Firebase does charge after some monthly limit but if you have fewer visitors on your site then you can give it a try. So that's why this method is actually for those people who are just starting to write Blogs or make websites. As static websites do not require any backend server.&lt;/p&gt;




&lt;h2&gt;
  
  
  Lets Begin
&lt;/h2&gt;

&lt;p&gt;We will use a tool called &lt;a href="https://www.httrack.com/"&gt;httrack&lt;/a&gt;. Download the tool from the website according to your Operating System.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the tool.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run your local WordPress server or if you have your site hosted somewhere then skip this step.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a new project and select a folder to store files.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tx4S0JCy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/41o1b4cujtpgdq98msxj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tx4S0JCy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/41o1b4cujtpgdq98msxj.png" alt="Create a new project" width="880" height="577"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4.Enter the URL of your site in the tool to scan your whole website. If it's on a local server then enter localhost: port-number.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FcgcWyV3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3r6k68ja6e5vppiex3ii.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FcgcWyV3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3r6k68ja6e5vppiex3ii.png" alt="enter you url" width="875" height="575"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5.After that config some basic options like which site you want to skip or any file type you want to ignore by the tool.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oIf0rCoS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2m85f5ijh7nbrsad9cvn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oIf0rCoS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2m85f5ijh7nbrsad9cvn.png" alt="Wait for process to complete" width="875" height="573"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;6.After that hit NEXT and sit back and relax for a few minutes.&lt;/p&gt;

&lt;p&gt;7.It depends on the size of your website home much time it will take to scan.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UAes_pgb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kzcb91ohojd77lhlz76k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UAes_pgb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kzcb91ohojd77lhlz76k.png" alt="Completed" width="875" height="571"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;8.After finished scanning you can see your whole site in the folder you have selected at the beginning. And note that every page of your site is now HTML means it's static and you can upload or host it at any free web server like Firebase.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cons
&lt;/h2&gt;

&lt;p&gt;Now let's discuss some of the cons of this approach.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cant monitor views and likes:&lt;/strong&gt; First is we cannot monitor the views and the like on the blog page. As it is only a static site no computation or counting can be done we can just show the page to the user nothing more than that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cant have comments:&lt;/strong&gt; We cannot have a comment section on our blog as there is no backend to store comments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Difficult to maintain:&lt;/strong&gt; It will be very hard to post a new article to your website as it requires publishing the article on your local site then scanning the site using this tool and then uploading it to the cloud.&lt;/p&gt;

&lt;p&gt;At last, I will only recommend using this method if your site is not changing content for many months and you want to run your site for free.&lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>cloud</category>
      <category>firebase</category>
      <category>html</category>
    </item>
    <item>
      <title>Firebase For Beginner : #2 Authentication</title>
      <dc:creator>Aakashp</dc:creator>
      <pubDate>Thu, 23 Sep 2021 12:07:26 +0000</pubDate>
      <link>https://dev.to/aakashp/firebase-for-beginner-2-authentication-4c7a</link>
      <guid>https://dev.to/aakashp/firebase-for-beginner-2-authentication-4c7a</guid>
      <description>&lt;p&gt;This is the second Blog in the series of Firebase For Beginner.&lt;/p&gt;

&lt;p&gt;If you have not already read the first part of it I will recommend to you please read the first part before reading this.&lt;br&gt;
&lt;a href="https://dev.to/aakashp/firebase-for-beginner-1-introduction-mdg"&gt;First Part&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the First part I had given the basic introduction to firebase its benefits and some features of firebase.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8FV9CziO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4p4d8nrrvjehr8pjux1a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8FV9CziO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4p4d8nrrvjehr8pjux1a.png" alt="Firebase Authentication"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now lets see one of the important feature of Firebase : &lt;strong&gt;Authentication&lt;/strong&gt;.&lt;br&gt;
Lets say you want to make a social media app or website, Then what is the First thing you need in your website?&lt;br&gt;
Login or Signup right.&lt;/p&gt;

&lt;p&gt;But if you want to implement login or signup feature by your own then it will take lot of time, it will require you to configure database, security, encryption and many other things.&lt;/p&gt;

&lt;p&gt;But Don't worry firebase Authentication is here to help you.&lt;br&gt;
Using authentication you don't have to configure anything. You have to just create a new firebase project and just tell firebase by which method you need to authenticate users, example by phone, email etc.&lt;/p&gt;
&lt;h2&gt;
  
  
  Steps to use Authentication in your project
&lt;/h2&gt;
&lt;h3&gt;
  
  
  1. Create a new firebase project
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;First goto Firebase and Create a new Project.&lt;/li&gt;
&lt;li&gt;Select your server location.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  2. Enable you authentication type
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Goto Authentication&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K0DFeJHF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/35z2cm9iwfs96mhzwc9e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K0DFeJHF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/35z2cm9iwfs96mhzwc9e.png" alt="Firebase Dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select the ways you like to authenticate your users.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HGc3GnC2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b8n8jzsqipffh2krc6k8.png" alt="Authentication Sign in methods"&gt;
&lt;/li&gt;
&lt;li&gt;I am now just enabling login with email and pass.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  3. Goto firebase authentication documentation to implement in your favourite language(&lt;a href="https://firebase.google.com/docs/auth"&gt;Firebase Docs&lt;/a&gt;).
&lt;/h3&gt;
&lt;h3&gt;
  
  
  Creating New User (Android-Java)
&lt;/h3&gt;

&lt;p&gt;First import the firebase and firebase AUTH dependencies.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dependencies {
    implementation platform('com.google.firebase:firebasebom:28.4.1')

    implementation 'com.google.firebase:firebase-auth'
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create FirebaseAuth object using getInstance method.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private FirebaseAuth mAuth;

// Initialize Firebase Auth
mAuth = FirebaseAuth.getInstance();
use createUserWithEmailAndPassword method to create a new user with the given email and password.
mAuth.createUserWithEmailAndPassword(email, password)
        .addOnCompleteListener(this, new OnCompleteListener&amp;lt;AuthResult&amp;gt;() {
    @Override
    public void onComplete(@NonNull Task&amp;lt;AuthResult&amp;gt; task) {
        if (task.isSuccessful()) {
        // Sign in success, update UI with the signed-in     user's    information
            FirebaseUser user = mAuth.getCurrentUser();

          } else {
             // If sign in fails, display a message to the user.

             Toast.makeText(EmailPasswordActivity.this, "Authentication failed.",Toast.LENGTH_SHORT).show();

                }
            }
        });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Verifying User
&lt;/h3&gt;

&lt;p&gt;Now lets see how to verify existing user with firebase auth.&lt;br&gt;
Its very simple just you need to call a method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mAuth.signInWithEmailAndPassword(email, password)
        .addOnCompleteListener(this, new OnCompleteListener&amp;lt;AuthResult&amp;gt;() {
            @Override
            public void onComplete(@NonNull Task&amp;lt;AuthResult&amp;gt; task) {
                if (task.isSuccessful()) {
                    // Sign in success, update UI with the signed-in user's information

                    FirebaseUser user = mAuth.getCurrentUser();

                } else {
                    // If sign in fails, display a message to the user.
                 Toast.makeText(EmailPasswordActivity.this, "Authentication failed.",Toast.LENGTH_SHORT).show();

                }
            }
        });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Benefits of using Authentication
&lt;/h1&gt;

&lt;p&gt;Now lets see what are the benefits of using firebase authentication instead of your own authentication system.&lt;/p&gt;

&lt;h4&gt;
  
  
  1.More Speed and Less Time
&lt;/h4&gt;

&lt;p&gt;First and very important benefit of using firebase is speed to development.&lt;/p&gt;

&lt;p&gt;Firebase Will increase your development speed of your project because you don't have to write any code for authentication or database you just have to create a object of firebase instance in your project and just use its authentication.&lt;/p&gt;

&lt;p&gt;Due to which the time to market of your project will also reduce and you will be able to focus just main functionality of your project rather than doing things which are already implement.&lt;/p&gt;

&lt;h4&gt;
  
  
  2.Easy to Implement
&lt;/h4&gt;

&lt;p&gt;The firebase authentication is easy to implement as compare to normal authentication system. As you have seen in above steps we have implemented authentication in just 2–3 steps.&lt;/p&gt;

&lt;h4&gt;
  
  
  3.Security
&lt;/h4&gt;

&lt;p&gt;Another most important feature of firebase is its security. As you all known firebase is backed by google and security of google is top notch. You don't have to worry about the security of your app or your users accounts or data. Firebase will take care all of that for you.&lt;/p&gt;

&lt;p&gt;Firebase uses different encryption algorithm to transfer the data so you don't need to implement the encryption and decryption of data by you own.&lt;/p&gt;

&lt;h4&gt;
  
  
  4.O AUTH(Login using Google, Facebook, Apple)
&lt;/h4&gt;

&lt;p&gt;Firebase provides a features to login with Google, Facebook, Apple and many other without any API implementation of platform. You just need to enable the login method in firebase Authentication dashboard and you are good to go.&lt;/p&gt;

&lt;h4&gt;
  
  
  5.Initially free to use
&lt;/h4&gt;

&lt;p&gt;If you are beginner or a student then you would not like to spend too much for just learning or testing. Firebase authentication is initially free for some limited no of users registration, so you can easily test and learn how it works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Disadvantages of using Firebase Authentication
&lt;/h2&gt;

&lt;p&gt;Every system has some pros and cons. No system is absolutely correct. Firebase Authentication has also some disadvantage let see them.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Vendor Lock-in&lt;/li&gt;
&lt;li&gt;Don't work in country where google is banned&lt;/li&gt;
&lt;li&gt;Limited query capabilities&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  When not to use authentication
&lt;/h2&gt;

&lt;p&gt;We have seen what is firebase authentication what are its advantages and disadvantages now lets see when not to use the Firebase Authentication.&lt;/p&gt;

&lt;h3&gt;
  
  
  1.Very Big Project
&lt;/h3&gt;

&lt;p&gt;If your project size is very big or you have lots of users or lots of data then you should not use firebase authentication. Because it will be very difficult to process that much data in firebase. And firebase don't allow to do much things on user Authentication.&lt;br&gt;
But if your project size is small or small user base then definitely firebase Authentication is a good start.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.Want to store data at own premises
&lt;/h3&gt;

&lt;p&gt;If your app generates or store very important data which is very precious to you then you should not use firebase because firebase store data in googles servers. And if you don't want to store data in google server then you should not use firebase. But you can use it to store data which is not so important so that it will reduce the load on your server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;So this was the basic introduction to Firebase authentication, we have seen how to use firebase authentication to login user and create new user account. We have also discussed the advantages and disadvantages of using firebase. And at last we have also seen where not to use firebase.&lt;/p&gt;

&lt;p&gt;So if you are a beginner then you should try firebase authentication in your project. It will save your lot of time.&lt;/p&gt;

</description>
      <category>firebase</category>
      <category>google</category>
      <category>authentication</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Firebase For Beginner : #1 Introduction</title>
      <dc:creator>Aakashp</dc:creator>
      <pubDate>Mon, 26 Jul 2021 10:43:48 +0000</pubDate>
      <link>https://dev.to/aakashp/firebase-for-beginner-1-introduction-mdg</link>
      <guid>https://dev.to/aakashp/firebase-for-beginner-1-introduction-mdg</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Hn8Rec3I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xovj15n35wiqtfxkuexx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Hn8Rec3I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xovj15n35wiqtfxkuexx.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
Hello reader,&lt;br&gt;
If you are a beginner developer then please read this , I will show you an amazing tool that will help you and your project to grow faster.&lt;br&gt;
And it is very simple and no advance knowledge needed.&lt;br&gt;
So if you are a beginner and are planning to develop an app which require database or storage or any server and you don't know any thing about server side programming then this is for you.&lt;/p&gt;

&lt;h3&gt;
  
  
  It's Google's Firebase!
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P91BqpS4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mcy5qxejhdkdtqeo3y8a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P91BqpS4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mcy5qxejhdkdtqeo3y8a.png" alt="image"&gt;&lt;/a&gt; &lt;br&gt;
Firebase is an amazing tool for your project. It provides lot of features for free and it will also reduce your time to code complex systems. Let say you want to develop an user login system then it will take a lot of time to develop. You have to check email address , check password, and also important thing is the security of users account and your system. But Firebase will do this for you in just few lines of code and few minutes.&lt;br&gt;
Now lets see some advantages of using firebase.&lt;/p&gt;

&lt;h3&gt;
  
  
  Advantages of using Firebase
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Easy to use
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kl2q8CoP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/crxs7fclf87l51qukrxw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kl2q8CoP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/crxs7fclf87l51qukrxw.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
Firebase is the most easy tool to use. Its simple dashboard will help you to navigate and find things easily. Firebases clean UI is the thing which attracts the beginners. There is no cmd or no code to get started Its just GUI. In few click you can host a website ,create a database, create user authentication system.&lt;/p&gt;

&lt;h4&gt;
  
  
  High Security
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bFPEcTaj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3rw5mhio9qtt8tepzdff.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bFPEcTaj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3rw5mhio9qtt8tepzdff.png" alt="image"&gt;&lt;/a&gt; &lt;br&gt;
Firebase is backed by Google And everybody knows the security of google. You don't need to secure your app you just focus on developing and firebase will take care of security. The data transfer is firebase is by default encrypted so you don't need to make or use an encryption algorithm And this is again one more advantage of firebase there fore developers prefer using it .&lt;/p&gt;

&lt;h4&gt;
  
  
  No downtime
&lt;/h4&gt;

&lt;p&gt;If you are setting up your own server then you have to take care of lot of things and one of it is server crash or down for maintenance . If you are using firebase then there is almost no downtime it is available 24x7 and one again if do it by yourself it will cost hell lot of money and time.&lt;/p&gt;

&lt;h4&gt;
  
  
  Detailed Documentation
&lt;/h4&gt;

&lt;p&gt;The documentation of firebase is so good that you have not to go anywhere or watch any tutorial. You can read documentation and understand everything about firebase its that simple.&lt;/p&gt;

&lt;h4&gt;
  
  
  Cross Platform
&lt;/h4&gt;

&lt;p&gt;One of the important feature of firebase is that it is cross platform means it support almost every platform and almost every language. So you don't need to learn a new language for firebase.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features of Firebase
&lt;/h3&gt;

&lt;p&gt;1.Realtime database&lt;br&gt;
2.Web hosting&lt;br&gt;
3.Authentication&lt;br&gt;
4.Messaging&lt;br&gt;
5.Analytics&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;If you are a beginner in this field and want to experience how backend system works then firebase is a great start. Firebase is so easy you just need a google account and you are ready to go. You can launch you app within few minutes with firebase. And almost all features of firebase are free initially.&lt;/p&gt;

</description>
      <category>firebase</category>
      <category>google</category>
      <category>serverless</category>
      <category>database</category>
    </item>
    <item>
      <title>URL shortner using NodeJS and firebase</title>
      <dc:creator>Aakashp</dc:creator>
      <pubDate>Thu, 22 Jul 2021 11:33:40 +0000</pubDate>
      <link>https://dev.to/aakashp/url-shortner-using-nodejs-and-firebase-4i29</link>
      <guid>https://dev.to/aakashp/url-shortner-using-nodejs-and-firebase-4i29</guid>
      <description>&lt;p&gt;Hello Guys,&lt;br&gt;
I will show you how you can make a simple url Shortner using Nodejs And firebase.&lt;/p&gt;
&lt;h1&gt;
  
  
  1 Create a project in firebase
&lt;/h1&gt;

&lt;p&gt;First create a new project in firebase and give it a name what ever you like.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xmCcxJdN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c02jfdmk8doezfl66o56.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xmCcxJdN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c02jfdmk8doezfl66o56.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GBzT1VGC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zg66cd2ar99xtrdzg68p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GBzT1VGC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zg66cd2ar99xtrdzg68p.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now create a Realtime database in firebase and select any server you want.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Tz0ad3eD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oqvkr14h01so2424zdj6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Tz0ad3eD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oqvkr14h01so2424zdj6.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Goto project settings and register your project as a web app.&lt;br&gt;
After registering firebase will give config details of your app.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vwq2nK2o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0xftq3vsg5a6d9894rsv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vwq2nK2o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0xftq3vsg5a6d9894rsv.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  2 Creating Backend Using NodeJS and ExpressJs
&lt;/h1&gt;

&lt;p&gt;Now open VS code and create a new folder&lt;br&gt;
In that folder create a JavaScript file Backend.js and Firebase.js&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DWAxFFcj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ydyw7vgokp4o83om88dg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DWAxFFcj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ydyw7vgokp4o83om88dg.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can also do it in single file but its good practice to separate different components of your app in different files.&lt;br&gt;
Now first initialize you NPM and Download some dependencies.&lt;br&gt;
Open terminal by pressing ctrl+shift+'&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm init
npm install express
npm install firebase
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now copy your firebase config details and create a new map in firebase.js file and paste it.&lt;br&gt;
Now add this two lines at the top of firebase.js so that we can user firebase and realtime database.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var firebase = require("firebase/app");
require("firebase/database");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now initialize firebase and export it so that we can use it in backend.js&lt;br&gt;
And at last your firebase.js will look like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var firebase = require("firebase/app");
require("firebase/database");

var firebaseConfig = {
    apiKey: "",
    authDomain: "urlshortner.firebaseapp.com",
    databaseURL: "https://urlshortner-rtdb.firebaseio.com",
    projectId: "urlshortner",
    storageBucket: "urlshortnerappspot.com",
    messagingSenderId: "",
    appId: "",
    measurementId: ""
  };

  // Initialize Firebase
firebase.initializeApp(firebaseConfig);

const database = firebase.database();

module.exports = {firebase,database};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now this is the backend.js file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const express = require('express')
var app = express()
const path = require("path");
const {firebase,database} = require("./firebase");



app.use(express.json());
app.use(express.urlencoded());
app.use(express.static(path.join(__dirname, 'views')));
app.set('view engine', 'ejs')

app.listen(5003, (err) =&amp;gt; {
console.log("APPLICATION IS RUNNIG");
})

app.get('/', (req, res) =&amp;gt; {

    res.render('index')

})
app.get('/favicon.ico', (req, res) =&amp;gt; {

    res.status(404).send("");


});



app.post('/process', (req, res) =&amp;gt; {
    console.log("post method")
const urlRegEx = "http|https?:\/\/(www\.)?[-a-zA-Z0–9@:%._\+~#=]{1,256}\.[a-zA-Z0–9()]{1,6}\b([-a-zA-Z0–9()@:%_\+.~#?&amp;amp;//=]*)";
var regEx = new RegExp(urlRegEx);
const longurl = req.body.longurl;

if (!longurl.match(regEx)) {
res.status(400).json({ message: "please enter valid url" });
return;
}

if (longurl.toString().length){
let shorturl =  (new Date()).getTime().toString(36);
addDatabaseEntry(shorturl, longurl);
res.status(200).json({
    longurl: longurl,
    shorturl: shorturl
})
}
})
app.get('/:shorturl', (req, res) =&amp;gt; {
const url = req.params.shorturl;
database.ref().child("urls").child(url).get().then((snapshot) =&amp;gt; {
if (snapshot.exists()) {
res.redirect(snapshot.val());
} else {
console.log("Wrong Url");
res.redirect('404');
}
}).catch((error) =&amp;gt; {
console.error(error);
});
});
function addDatabaseEntry(shorturl, longurl) {
database.ref("urls/" + shorturl).set(longurl);
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First 10 lines are the initialization of some packages. If you have some knowledge about http server then you will easily understand this code.&lt;/p&gt;

&lt;p&gt;At first we are creating an http server at port 5003. Here we are only creating the Backend of the server . We are sending the long URL in the post request and then the server will verify if the URL is valid or not and if it is valid then it will generate a short URL for this long URL and store it in the database.&lt;/p&gt;

&lt;p&gt;There are three main Functions in backend.js&lt;/p&gt;

&lt;p&gt;1.addDatabaseEntry&lt;br&gt;
2.Post request to generate short URL&lt;br&gt;
3.Get request to redirect to long URL&lt;/p&gt;

&lt;p&gt;addDatabaseEntry will take the long URL and short URL and store it in the database.&lt;/p&gt;

&lt;p&gt;app.post will take a long URL and will first check if the URL is valid or not and if valid then it will create a short URL and add the entry to the database.&lt;/p&gt;

&lt;p&gt;app.get will take the short URL from the user. if the URL is present in the database it will redirect the user to long URL and if URL is not present then it will give an error.&lt;br&gt;
And that's all our URL shortner is ready. You can also get this code from my GitHub repository. Now lets give it some long URL.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/aakashpsindhi/urlshortener"&gt;GitHub - urlshortener&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  3 Testing
&lt;/h1&gt;

&lt;p&gt;For testing I have created basic HTML page. If you want to see it you can get it on my GitHub. &lt;br&gt;
Entering Long URL&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rwUqH8cw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gjsvyrmwwcotgdc7pfwx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rwUqH8cw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gjsvyrmwwcotgdc7pfwx.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Converted to short URL&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o0yDdc7m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/68ihogki31lo8p4hkcz6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o0yDdc7m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/68ihogki31lo8p4hkcz6.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Redirect to long URL&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U_fZYF9i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mjg7oe0g4o9wso7ptvd0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U_fZYF9i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mjg7oe0g4o9wso7ptvd0.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0jMcBEZB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mgxlwr72sbtu4par1mbf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0jMcBEZB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mgxlwr72sbtu4par1mbf.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
