How To Get Yesterday Date In Flutter ?

Hello Dev’s Today now in this post i will show you How To Get Yesterday Date In Flutter ? Here now, let’s see the article of flutter get the yesterday date Example. Now in this example i will help you How we can Get Yesterday Date in Flutter? I would like to show you a new tutorial how to get the previous date in Flutter? So in this article i will goes in detailed on flutter current date and time. i will be do the following things for how we can get yesterday date in flutter a current.

Here i will give you a very simple example of flutter to get current yesterday date

So let’s see the bellow example:

Step 1: Create Flutter Project

At first Follow the along with the setup, we can be creating an Flutter app.

$flutter create flutter_get_current_yesterday_tutorial   

Then use this Navigate to the project directory:

$cd flutter_get_current_yesterday_tutorial   
Step 2: Main File

Finally need to Create a main.dart file in the lib directory

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
    Widget build(BuildContext context) {
        return MaterialApp(
            home: Scaffold(
                appBar: AppBar(
                    title: Text('Get Yesterday Date')
                body: Center(
                    child: GetDate()

class GetDate extends StatefulWidget {

    _GetDateState createState() => _GetDateState();


class _GetDateState extends State<GetDate> {

    String finalDate = '';


        var date = new;

        var dateParse = DateTime.parse(date);

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

        setState(() {

            finalDate = formattedDate.toString() ;



    Widget build(BuildContext context) {
        return Scaffold(
            body: Center(
                child: Column(
                    children: <Widget>[

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

                            onPressed: getCurrentDate,
                            textColor: Colors.white,
                            padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
                            child: Text('Click Here To Get Yesterday Date'),

Read Also: How to Create Random String in React Native?


About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →