How to format date in Flutter

Usually we are using different formats for date according to our needs. How do you format date in Dart/Flutter using custom format. A dependency library can save us.

To use this we need to add and the following lines in the dependencies section of pubspec.yaml file and run my favorite Flutter command pub get 

dependencies:
    date_format:

Add the package using Import

import 'package:date_format/date_format.dart';

Using the formatDate function we can format date (not string ) as wanted with a list of formats as follows

formatDate(box.getAt(index).projectAsDate,
    [dd, '/', mm, '/', yy]),

We can replace the ‘/’ (slash) with whatever we want. Here is the link to the package

Flutter Projects

Hivedb-Flutter Todo


This project store todo items locally using NoSQL database, Hivedb, which is written in dart. Damn blazingly fast

Flutter Project Planner


A MongoDB-Flutter cloud application for project management

Flutter-Kitchen-Cart


A firebase – Flutter sample application for iOS and Android

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.