How to Get Tomorrow Date in Flutter?

Jun 18, 2022 . Admin

Hi friends,

If you need to see example of How to Get Tomorrow Date in Flutter?. if you have question about The date of Tomorrow in flutter then I will give simple example with solution. let’s discuss about how to get tomorrow date in flutter app. Here you will learn Flutter Get Tomorrow Date Example.

I will give you simple Example of how to get tomorrow date in flutter and time

Let's get started with Flutter Get Previous Date Example.

So let's see bellow example:

Step 1: Create Flutter Project

Follow along with the setup, you will be creating an Flutter app.

$flutter create flutter_get_tomorrow_date_tutorial   

Navigate to the project directory:

$cd flutter_get_tomorrow_date_tutorial   
Step 2: Main File

Create a main.dart file in the lib directory

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
        return MaterialApp(
            home: Scaffold(
                appBar: AppBar(
                    title: Text('Get Tomorrow Date')
                ),
                body: Center(
                    child: GetDate()
                )
            )
        );
    }
}

class GetDate extends StatefulWidget {

    _GetDateState createState() => _GetDateState();

}

class _GetDateState extends State<GetDate> {

    String finalDate = '';

    getCurrentDate(){

        var date = new DateTime.now().add(Duration(days:1)).toString();

        var dateParse = DateTime.parse(date);

        var formattedDate = "${dateParse.day}/${dateParse.month}/${dateParse.year}";

        setState(() {

            finalDate = formattedDate.toString() ;

        });

    }

    @override
    Widget build(BuildContext context) {
        return Scaffold(
            body: Center(
                child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[

                        Padding(
                            padding: EdgeInsets.all(8.0),
                            child :
                            Text("Date = $finalDate", style: TextStyle(fontSize: 20), textAlign: TextAlign.center,)
                        ),

                        RaisedButton(
                            onPressed: getCurrentDate,
                            color: Colors.green,
                            textColor: Colors.white,
                            padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
                            child: Text('Click Here To Get Tomorrow Date'),
                        ),
                    ],
                ),
            )
        );
    }
}
Run this Debug App Output :

I hope it will help you....

#Flutter