From ab6ea575d70e699f376c0bb49d5326d9126832d4 Mon Sep 17 00:00:00 2001 From: Ruidy Date: Sat, 24 Jul 2021 10:15:55 +0200 Subject: [PATCH] format date --- lib/calculator.dart | 5 ++++- pubspec.lock | 7 +++++++ pubspec.yaml | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/calculator.dart b/lib/calculator.dart index b92e992..c96366d 100644 --- a/lib/calculator.dart +++ b/lib/calculator.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'profile.dart'; @@ -30,7 +31,9 @@ class _CalculatorPageState extends State { (1.2 * bodyMassIndex() + .23 * _age - 10.8 * _gender - 5.4).round(); Future _saveResults() async { - var now = DateTime.now().toString(); + var dateFormatter = DateFormat("dd/MM/yyyy"); + var now = dateFormatter.format(DateTime.now()); + SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.setStringList( now, diff --git a/pubspec.lock b/pubspec.lock index 27d7757..a86dc7b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -86,6 +86,13 @@ packages: description: flutter source: sdk version: "0.0.0" + intl: + dependency: "direct main" + description: + name: intl + url: "https://pub.dartlang.org" + source: hosted + version: "0.17.0" js: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 3db82d8..1e565b0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -25,6 +25,7 @@ dependencies: sdk: flutter shared_preferences: 2.0.6 + intl: ^0.17.0 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.