format date

This commit is contained in:
Ruidy 2021-07-24 10:15:55 +02:00
parent 8c90fdc85e
commit ab6ea575d7
3 changed files with 12 additions and 1 deletions

View file

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'profile.dart'; import 'profile.dart';
@ -30,7 +31,9 @@ class _CalculatorPageState extends State<CalculatorPage> {
(1.2 * bodyMassIndex() + .23 * _age - 10.8 * _gender - 5.4).round(); (1.2 * bodyMassIndex() + .23 * _age - 10.8 * _gender - 5.4).round();
Future<void> _saveResults() async { Future<void> _saveResults() async {
var now = DateTime.now().toString(); var dateFormatter = DateFormat("dd/MM/yyyy");
var now = dateFormatter.format(DateTime.now());
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setStringList( prefs.setStringList(
now, now,

View file

@ -86,6 +86,13 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
intl:
dependency: "direct main"
description:
name: intl
url: "https://pub.dartlang.org"
source: hosted
version: "0.17.0"
js: js:
dependency: transitive dependency: transitive
description: description:

View file

@ -25,6 +25,7 @@ dependencies:
sdk: flutter sdk: flutter
shared_preferences: 2.0.6 shared_preferences: 2.0.6
intl: ^0.17.0
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.