clear measurements

This commit is contained in:
Ruidy 2021-07-24 10:32:33 +02:00
parent ab6ea575d7
commit 699c961b85

View file

@ -1,3 +1,4 @@
import 'package:bmi_calculator/calculator.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
@ -32,13 +33,22 @@ class _ProfilePageState extends State<ProfilePage> {
super.initState();
}
Future<void> clearMeasurements() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.clear();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Your profile"),
),
body: ListView.builder(
body: Column(
children: [
ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
padding: const EdgeInsets.all(8),
itemCount: storedMeasurements.length,
itemBuilder: (BuildContext context, int index) {
@ -61,6 +71,14 @@ class _ProfilePageState extends State<ProfilePage> {
);
},
),
ElevatedButton(
onPressed: () {
clearMeasurements();
Navigator.pushNamed(context, CalculatorPage.routeName);
},
child: Text("Clear Measurements"))
],
),
);
}
}