flutter_easy_date 0.0.2 copy "flutter_easy_date: ^0.0.2" to clipboard
flutter_easy_date: ^0.0.2 copied to clipboard

Flutter package for formatting dates and times dynamically based on locale.

EasyDate #

flutter_easy_date

EasyDate is a Flutter package for formatting dates and times dynamically based on locale.

Usage #

Initialize the package #

Before using EasyDate, initialize the locale data:

import 'package:flutter_easy_date/flutter_easy_date.dart';
void main() async {
  await EasyDate.initialize();
}

Format DateTime, Date or Time #

Use default device Locale

DateTime now = DateTime.now();

String formattedDate = EasyDate.date(now);  // Uses device locale
print(formattedDate);

String formattedDateTime = EasyDate.dateTime(now);
print(formattedDateTime); // Output: MM/dd/yyyy HH:mm:ss


String formattedTime = EasyDate.time(now, showSeconds: false);
print(formattedTime); // Output: HH:mm

Format DateTime, Date or Time - Specify Locale #

DateTime now = DateTime.now();

String formattedDate = EasyDate.date(now, locale: Locale('de'));  // Uses device locale
print(formattedDate);

String formattedDateTime = EasyDate.dateTime(now, locale: Locale('de'));
print(formattedDateTime); // Output: MM/dd/yyyy HH:mm:ss


String formattedTime = EasyDate.time(now, locale: Locale('de'));
print(formattedTime); // Output: HH:mm

Supported Locales #

The package supports all locales available in the intl package. If an unsupported locale is used, the format defaults to MM/dd/yyyy.

License #

MIT License

2
likes
160
points
12
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter package for formatting dates and times dynamically based on locale.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, intl

More

Packages that depend on flutter_easy_date