How to convert Date To String & Double to Currency in Flutter or Dart ?

Most fo the Flutter Developer has question like how to convert Date to String with Format or Double to Currency Format in Flutter?

You can use the intl package (installer) to format dates.

library will solve most of the folrmating issue in flutter.

This library provides internationalization and localization. This includes message formatting and replacement, date and number formatting and parsing, and utilities for working with Bidirectional text. DateFormat is for formatting and parsing dates in a locale-sensitive manner.

Date Formating (DateFormat)

import 'package:intl/intl.dart';

main() {
  var now = new;
  var formatter = new DateFormat('yyyy-MMM-dd');
  String formatted = formatter.format(now);
  print(formatted); // something like 2019-Jun-20

Supported Formats

 ICU Name                   Skeleton
 --------                   --------
 DAY                          d
 ABBR_WEEKDAY                 E
 WEEKDAY                      EEEE
 NUM_MONTH                    M
 NUM_MONTH_DAY                Md
 ABBR_MONTH                   MMM
 ABBR_MONTH_DAY               MMMd
 MONTH                        MMMM
 MONTH_DAY                    MMMMd
 ABBR_QUARTER                 QQQ
 QUARTER                      QQQQ
 YEAR                         y
 YEAR_NUM_MONTH               yM
 YEAR_NUM_MONTH_DAY           yMd
 YEAR_ABBR_MONTH              yMMM
 YEAR_MONTH                   yMMMM
 YEAR_MONTH_DAY               yMMMMd
 YEAR_QUARTER                 yQQQQ
 HOUR24                       H
 HOUR24_MINUTE                Hm
 HOUR                         j
 HOUR_MINUTE                  jm
 HOUR_MINUTE_SECOND           jms
 HOUR_MINUTE_TZ               jmz
 HOUR_GENERIC_TZ              jv
 HOUR_TZ                      jz
 MINUTE                       m
 MINUTE_SECOND                ms
 SECOND                       s


Currency Formatting (NumberFormat)

import 'package:intl/intl.dart';
main() {
  double flutterBalance = 94510.60;
  final oCcy = new NumberFormat("#,##0.00", "en_US");
  String formatted = oCcy.format(flutterBalance);
  print(formatted); // something like 94,510.60

Thanks for reading, and hopefully this was helpful!