<?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: ARUN</title>
    <description>The latest articles on DEV Community by ARUN (@arun100203).</description>
    <link>https://dev.to/arun100203</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%2F965535%2F07f010c1-6e92-4e10-8b24-339e90dadb7b.jpeg</url>
      <title>DEV Community: ARUN</title>
      <link>https://dev.to/arun100203</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arun100203"/>
    <language>en</language>
    <item>
      <title>useEffect Hook💥 in React</title>
      <dc:creator>ARUN</dc:creator>
      <pubDate>Tue, 24 Oct 2023 13:01:49 +0000</pubDate>
      <link>https://dev.to/arun100203/useeffect-hook-in-react-1adp</link>
      <guid>https://dev.to/arun100203/useeffect-hook-in-react-1adp</guid>
      <description>&lt;p&gt;React Hooks are a feature introduced in version 16.8 of React. They allow function components to have access to state and other React features, such as lifecycle methods, without the need for class components.&lt;/p&gt;

&lt;p&gt;Today we are seeing about useEffect hook in react.&lt;/p&gt;

&lt;p&gt;The useEffect Hook allows you to perform side effects in your components.&lt;br&gt;
Some examples of side effects are: fetching data, directly updating the DOM, and timers.&lt;br&gt;
useEffect accepts two arguments. The second argument is optional.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;useEffect(&amp;lt;function&amp;gt;, &amp;lt;dependency&amp;gt;)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;function&amp;gt;&lt;/code&gt; — inside the function we write a callBack function.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;dependency&amp;gt;&lt;/code&gt; — inside the dependency we should give a dependency array.&lt;/p&gt;

&lt;p&gt;the below example have contents in app.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import './App.css';
import { useState, useEffect } from 'react';

function App() {
  const [count, setCount] = useState(0);

  useEffect(()=&amp;gt;{
    // this hook will run at the time when our component mounts.

    console.log('the count is',count);

    // this is optional return statement, is that what will happen when
    // the component unmounts.

    return () =&amp;gt;{
        console.log('the component was unmounted')
    }

    // what we are using inside of useEffect we must metion that 
    // inside of dependency array. 
    // the code inside the useeffect will execute once, aftee that it 
    // won't execuded when we forget to give values inside the dependency array

  }, [count]);

  return (
    &amp;lt;div className='App'&amp;gt;
      &amp;lt;p&amp;gt;Count: {count}&amp;lt;/p&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; setCount((c) =&amp;gt; c + 1)}&amp;gt;+&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we should know that how useEffect works, it will execute the code at the component mounts after that at every time we update the values inside the dependency array the component will destroy and rebuild again,&lt;br&gt;
that is the return function inside the useEffect hook will execute at the time.&lt;/p&gt;

&lt;p&gt;The output for this above code will be,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xIY94nf6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qb7i0zreg6r0qiys2luo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xIY94nf6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qb7i0zreg6r0qiys2luo.png" alt="output image" width="274" height="251"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;you will see the changes in the console by inspecting that webpage&lt;/p&gt;

&lt;p&gt;the console will be,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U3fTob4V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/v2/resize:fit:720/format:webp/1%2ABY4DH1Ifsnp4maqmsxKBsA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U3fTob4V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/v2/resize:fit:720/format:webp/1%2ABY4DH1Ifsnp4maqmsxKBsA.png" alt="output in console" width="720" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At every time the count value changes the component will destroy and again it would mount in the component tree.&lt;/p&gt;

&lt;p&gt;I hope that you will have a better understanding of useEffect, If you have any doubts comment in this post.&lt;/p&gt;

&lt;p&gt;Thank you, Have a nice day 💖…….&lt;/p&gt;

</description>
      <category>react</category>
      <category>useeffect</category>
      <category>hooks</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Flask Calculator</title>
      <dc:creator>ARUN</dc:creator>
      <pubDate>Thu, 02 Mar 2023 01:12:46 +0000</pubDate>
      <link>https://dev.to/arun100203/flask-calculator-1041</link>
      <guid>https://dev.to/arun100203/flask-calculator-1041</guid>
      <description>&lt;p&gt;At first many of them create their first project as Calculator, Now here I will explain how I do a calculator project using flask.&lt;/p&gt;

&lt;p&gt;Flask is a Framework in python, Which was lightweight and everyone has quickly learn about flask. Now for this you must have basic knowledge of html, css, javaScript, and python. &lt;/p&gt;

&lt;p&gt;The Following html code is the UI for calculator which contains css and javaScript file also.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;title&amp;gt;Calculator&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
     &amp;lt;style&amp;gt;
        table {
            border: 1px solid black;
            margin-left: auto;
            margin-right: auto;
        }

        button {
            width: 100%;
            padding: 20px 40px;
            background-color: grey;
            color: white;
            font-size: 24px;
            font-weight: bold;
            border: none;
            border-radius: 5px;
        }

        input[type="text"] {
            padding: 20px 20px;
            font-size: 20px;
            border-radius: 5px;
            border: 2px solid black;
        }
    &amp;lt;/style&amp;gt;
    &amp;lt;script&amp;gt;
        function dis(val) {
            document.getElementById("result").value += val
        }

        function clr() {
            document.getElementById("result").value = ""
        }
    &amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;form method="post"&amp;gt;
    &amp;lt;table cellspacing="5"&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;&amp;lt;button type="button" onclick="clr()"&amp;gt;del&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td colspan="3" &amp;gt; &amp;lt;input type="text" id="result" name="result" value="{{ answer }}"&amp;gt;&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
           &amp;lt;td&amp;gt;&amp;lt;button type="button" onclick="dis('1')"&amp;gt;1&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;button type="button" onclick="dis('2')"&amp;gt;2&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;button type="button" onclick="dis('3')"&amp;gt;3&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;button type="button" onclick="dis('+')"&amp;gt;+&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;&amp;lt;button type="button" onclick="dis('4')"&amp;gt;4&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;button type="button" onclick="dis('5')"&amp;gt;5&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;button type="button" onclick="dis('6')"&amp;gt;6&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;button type="button" onclick="dis('-')"&amp;gt;-&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;&amp;lt;button type="button" onclick="dis('7')"&amp;gt;7&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;button type="button" onclick="dis('8')"&amp;gt;8&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;button type="button" onclick="dis('9')"&amp;gt;9&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;button type="button" onclick="dis('*')"&amp;gt;*&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;&amp;lt;button type="button" onclick="dis('.')"&amp;gt;.&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;button type="button" onclick="dis('0')"&amp;gt;0&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;button type="submit"&amp;gt;=&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;button type="button" onclick="dis('/')"&amp;gt;/&amp;lt;/button&amp;gt;&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
    &amp;lt;/table&amp;gt;
&amp;lt;/form&amp;gt;


&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This was an simple UI. When we click &lt;code&gt;=&lt;/code&gt; then this form will submit and then python file will run, then it gives result and it will show in the main page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from flask import Flask, render_template, request
app = Flask(__name__)


@app.route('/')
def home():
    return render_template('index.html')


@app.route('/', methods=['POST'])
def result():
    ans = 0
    if request.method == 'POST':
        try:
            ans = eval(str(request.form.get("result")))
        except:
            ans = "Invalid opertaion"

    return render_template('index.html', answer=ans)


if __name__ == "__main__":
    app.run(debug=True)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;for Flask you need to create a folder template and then write your html file inside of it.&lt;/p&gt;

&lt;p&gt;In this python file at first I import Flask, then create name for app then make the default route &lt;code&gt;/&lt;/code&gt; then home() renders our html file.&lt;/p&gt;

&lt;p&gt;Then create a function called result, which receives the request from post method and then it calculates the result value by using &lt;code&gt;eval()&lt;/code&gt; in python. In main function I run my app.&lt;/p&gt;

&lt;p&gt;you can find my source code &lt;a href="https://github.com/Arun100203/Flask-Calculator/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you can't understand this you could learn some basics and then come back and see this, consistent learning definitely gives you success.&lt;/p&gt;

&lt;p&gt;THANK YOU ❤️.....&lt;/p&gt;

</description>
      <category>hackathon</category>
      <category>writing</category>
      <category>career</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Age Calculator in Flutter</title>
      <dc:creator>ARUN</dc:creator>
      <pubDate>Sun, 26 Feb 2023 01:32:47 +0000</pubDate>
      <link>https://dev.to/arun100203/age-calculator-in-flutter-1a48</link>
      <guid>https://dev.to/arun100203/age-calculator-in-flutter-1a48</guid>
      <description>&lt;p&gt;In this post I will share about Age Calculator in Flutter, this Calculator finds the Age in years, months, days, hours.&lt;/p&gt;

&lt;p&gt;Let's get Started...&lt;/p&gt;

&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Get the Birth day of user by using datepicker, then find the difference between birthday and current day.&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;void _showPicker() {&lt;br&gt;
    showDatePicker(&lt;br&gt;
        context: context,&lt;br&gt;
        firstDate:  DateTime(1900),&lt;br&gt;
        initialDate:  DateTime(2023),&lt;br&gt;
        lastDate: DateTime.now()).then((DateTime? dt) {&lt;br&gt;
      selectedYear = dt?.year;&lt;br&gt;
      selectedDay = dt?.day;&lt;br&gt;
      selectedMon = dt?.month;&lt;br&gt;
      calculateAge();&lt;br&gt;
    });&lt;br&gt;
  }&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;this function is used to get the birthdate of user

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

&lt;/div&gt;



&lt;p&gt;age = (2023 - selectedYear).toDouble();&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;this line is used to find the age in years.

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

&lt;/div&gt;



&lt;p&gt;DateTime date1 = DateTime(selectedYear, selectedMon, selectedDay);&lt;br&gt;
      day = double.parse(date2.difference(date1).inDays.toString());&lt;br&gt;
      month =  double.parse((date2.difference(date1).inDays / 30).floor().toString());&lt;br&gt;
      hours = day*24.0;&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;this line is used to find the age in months, days, hours, And these calculations are approximate values.

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

&lt;/div&gt;



&lt;p&gt;&lt;a class="mentioned-user" href="https://dev.to/override"&gt;@override&lt;/a&gt;&lt;br&gt;
  void initState() {&lt;br&gt;
    animationController =  AnimationController(&lt;br&gt;
        vsync: this, duration:  Duration(milliseconds: 1500));&lt;br&gt;
    animation = animationController;&lt;br&gt;
    animation1 = animationController;&lt;br&gt;
    animation2 = animationController;&lt;br&gt;
    animation3 = animationController;&lt;br&gt;
    super.initState();&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;&lt;a class="mentioned-user" href="https://dev.to/override"&gt;@override&lt;/a&gt;&lt;br&gt;
  void dispose() {&lt;br&gt;
    animationController.dispose();&lt;br&gt;
    super.dispose();&lt;br&gt;
  }&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;And I use some Animations to visualize the results.

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

&lt;/div&gt;



&lt;p&gt;animation =  Tween(begin: animation.value, end: age).animate(&lt;br&gt;
           CurvedAnimation(&lt;br&gt;
              curve: Curves.fastOutSlowIn, parent: animationController));&lt;br&gt;
      animation1 = Tween(begin: animation.value, end: month).animate(&lt;br&gt;
          CurvedAnimation(&lt;br&gt;
              curve: Curves.fastOutSlowIn, parent: animationController));&lt;br&gt;
      animation2 = Tween(begin: animation.value, end: day).animate(&lt;br&gt;
          CurvedAnimation(&lt;br&gt;
              curve: Curves.fastOutSlowIn, parent: animationController));&lt;br&gt;
      animation3 = Tween(begin: animation.value, end: hours).animate(&lt;br&gt;
          CurvedAnimation(&lt;br&gt;
              curve: Curves.fastOutSlowIn, parent: animationController));&lt;br&gt;
      animationController.forward(from: 0.0);&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;These lines are used to show the result in animated view.

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

&lt;/div&gt;



&lt;p&gt;&lt;a class="mentioned-user" href="https://dev.to/override"&gt;@override&lt;/a&gt;&lt;br&gt;
  Widget build(BuildContext context) {&lt;br&gt;
    return Scaffold(&lt;br&gt;
      appBar:  AppBar(&lt;br&gt;
        title:  Text("Age Calculator"),&lt;br&gt;
      ),&lt;br&gt;
      body: Center(&lt;br&gt;
        child: Column(&lt;br&gt;
          mainAxisAlignment: MainAxisAlignment.center,&lt;br&gt;
          children: [&lt;br&gt;
             OutlinedButton(&lt;br&gt;
              onPressed: _showPicker,&lt;br&gt;
              child:  Text(selectedYear != null&lt;br&gt;
                  ? selectedYear.toString()&lt;br&gt;
                  : "Select your year of birth"),&lt;br&gt;
            ),&lt;br&gt;
             const Padding(&lt;br&gt;
              padding: EdgeInsets.all(20.0),&lt;br&gt;
            ),&lt;br&gt;
             AnimatedBuilder(&lt;br&gt;
              animation: animation,&lt;br&gt;
              builder: (context, child) =&amp;gt; Text(&lt;br&gt;
                "Your Age in years ${animation.value.toStringAsFixed(0)}"&lt;br&gt;
                    "\nYour Age in months ${animation1.value.toStringAsFixed(0)}"&lt;br&gt;
                    "\nYour Age in days ${animation2.value.toStringAsFixed(0)}"&lt;br&gt;
                    "\nYour Age in hours ${animation3.value.toStringAsFixed(0)}",&lt;br&gt;
                style:  const TextStyle(&lt;br&gt;
                    fontSize: 30.0,&lt;br&gt;
                    fontWeight: FontWeight.bold,&lt;br&gt;
                    fontStyle: FontStyle.italic),&lt;br&gt;
              ),&lt;br&gt;
            )&lt;br&gt;
          ],&lt;br&gt;
        ),&lt;br&gt;
      ),&lt;br&gt;
    );&lt;br&gt;
  }&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
This was the build method for our project.

And the following is the entire code for `main.dart` file

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

&lt;/div&gt;



&lt;p&gt;import 'package:flutter/material.dart';&lt;br&gt;
import 'package:age_calculator/age_calculator.dart';&lt;/p&gt;

&lt;p&gt;void main() =&amp;gt; runApp(MaterialApp(&lt;br&gt;
    debugShowCheckedModeBanner: false,&lt;br&gt;
    theme:  ThemeData(primarySwatch: Colors.grey),&lt;br&gt;
    home:  MyHomePage()));&lt;/p&gt;

&lt;p&gt;class MyHomePage extends StatefulWidget {&lt;br&gt;
  &lt;a class="mentioned-user" href="https://dev.to/override"&gt;@override&lt;/a&gt;&lt;br&gt;
  _MyHomePageState createState() =&amp;gt; new _MyHomePageState();&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;class _MyHomePageState extends State with SingleTickerProviderStateMixin {&lt;br&gt;
  double age = 0.0;&lt;br&gt;
  double month = 0.0;&lt;br&gt;
  double day = 0.0;&lt;br&gt;
  double hours = 0.0;&lt;br&gt;
  final date2 = DateTime.now();&lt;br&gt;
  var selectedYear ; // for setting year&lt;br&gt;
  var selectedDay ; // for setting date&lt;br&gt;
  var selectedMon ; // for setting month&lt;br&gt;
  late Animation animation; // this denoting age animation&lt;br&gt;
  late Animation animation1; // this denoting month animation&lt;br&gt;
  late Animation animation2; // this denoting date animation&lt;br&gt;
  late Animation animation3; // this denoting hour animation&lt;br&gt;
  late AnimationController animationController;&lt;/p&gt;

&lt;p&gt;&lt;a class="mentioned-user" href="https://dev.to/override"&gt;@override&lt;/a&gt;&lt;br&gt;
  void initState() {&lt;br&gt;
    animationController =  AnimationController(&lt;br&gt;
        vsync: this, duration:  Duration(milliseconds: 1500));&lt;br&gt;
    animation = animationController;&lt;br&gt;
    animation1 = animationController;&lt;br&gt;
    animation2 = animationController;&lt;br&gt;
    animation3 = animationController;&lt;br&gt;
    super.initState();&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;&lt;a class="mentioned-user" href="https://dev.to/override"&gt;@override&lt;/a&gt;&lt;br&gt;
  void dispose() {&lt;br&gt;
    animationController.dispose();&lt;br&gt;
    super.dispose();&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;void _showPicker() {&lt;br&gt;
    showDatePicker(&lt;br&gt;
        context: context,&lt;br&gt;
        firstDate:  DateTime(1900),&lt;br&gt;
        initialDate:  DateTime(2023),&lt;br&gt;
        lastDate: DateTime.now()).then((DateTime? dt) {&lt;br&gt;
      selectedYear = dt?.year;&lt;br&gt;
      selectedDay = dt?.day;&lt;br&gt;
      selectedMon = dt?.month;&lt;br&gt;
      calculateAge();&lt;br&gt;
    });&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;void calculateAge() {&lt;br&gt;
    setState(() {&lt;br&gt;
      age = (2023 - selectedYear).toDouble();&lt;br&gt;
      DateTime date1 = DateTime(selectedYear, selectedMon, selectedDay);&lt;br&gt;
      day = double.parse(date2.difference(date1).inDays.toString());&lt;br&gt;
      month =  double.parse((date2.difference(date1).inDays / 30).floor().toString());&lt;br&gt;
      hours = day*24.0;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  animation =  Tween&amp;lt;double&amp;gt;(begin: animation.value, end: age).animate(
       CurvedAnimation(
          curve: Curves.fastOutSlowIn, parent: animationController));
  animation1 = Tween&amp;lt;double&amp;gt;(begin: animation.value, end: month).animate(
      CurvedAnimation(
          curve: Curves.fastOutSlowIn, parent: animationController));
  animation2 = Tween&amp;lt;double&amp;gt;(begin: animation.value, end: day).animate(
      CurvedAnimation(
          curve: Curves.fastOutSlowIn, parent: animationController));
  animation3 = Tween&amp;lt;double&amp;gt;(begin: animation.value, end: hours).animate(
      CurvedAnimation(
          curve: Curves.fastOutSlowIn, parent: animationController));
  animationController.forward(from: 0.0);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;&lt;a class="mentioned-user" href="https://dev.to/override"&gt;@override&lt;/a&gt;&lt;br&gt;
  Widget build(BuildContext context) {&lt;br&gt;
    return Scaffold(&lt;br&gt;
      appBar:  AppBar(&lt;br&gt;
        title:  Text("Age Calculator"),&lt;br&gt;
      ),&lt;br&gt;
      body: Center(&lt;br&gt;
        child: Column(&lt;br&gt;
          mainAxisAlignment: MainAxisAlignment.center,&lt;br&gt;
          children: [&lt;br&gt;
             OutlinedButton(&lt;br&gt;
              onPressed: _showPicker,&lt;br&gt;
              child:  Text(selectedYear != null&lt;br&gt;
                  ? selectedYear.toString()&lt;br&gt;
                  : "Select your year of birth"),&lt;br&gt;
            ),&lt;br&gt;
             const Padding(&lt;br&gt;
              padding: EdgeInsets.all(20.0),&lt;br&gt;
            ),&lt;br&gt;
             AnimatedBuilder(&lt;br&gt;
              animation: animation,&lt;br&gt;
              builder: (context, child) =&amp;gt; Text(&lt;br&gt;
                "Your Age in years ${animation.value.toStringAsFixed(0)}"&lt;br&gt;
                    "\nYour Age in months ${animation1.value.toStringAsFixed(0)}"&lt;br&gt;
                    "\nYour Age in days ${animation2.value.toStringAsFixed(0)}"&lt;br&gt;
                    "\nYour Age in hours ${animation3.value.toStringAsFixed(0)}",&lt;br&gt;
                style:  const TextStyle(&lt;br&gt;
                    fontSize: 30.0,&lt;br&gt;
                    fontWeight: FontWeight.bold,&lt;br&gt;
                    fontStyle: FontStyle.italic),&lt;br&gt;
              ),&lt;br&gt;
            )&lt;br&gt;
          ],&lt;br&gt;
        ),&lt;br&gt;
      ),&lt;br&gt;
    );&lt;br&gt;
  }&lt;br&gt;
}&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
Here i use one external package called `Age_Calculator`.

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

&lt;/div&gt;



&lt;p&gt;dependencies:&lt;br&gt;
  flutter:&lt;br&gt;
    sdk: flutter&lt;/p&gt;

&lt;p&gt;# The following adds the Cupertino Icons font to your application.&lt;br&gt;
  # Use with the CupertinoIcons class for iOS style icons.&lt;br&gt;
  cupertino_icons: ^1.0.2&lt;br&gt;
  age_calculator: ^1.0.0  # include here&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;So you need to insert that in your `pubspec.yaml` file.

---

This was the final result.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0k2m61ygyd6azagppbsy.png)
You can also check this by [here](https://arun.engineer/Age_Calculator/).

If you Like this, then put Likes and If you have any Queries then Comment your queries.

Thank you 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>flutter</category>
    </item>
  </channel>
</rss>
