mirror of
https://github.com/rjNemo/bmi_calculator_app
synced 2026-06-06 02:16:41 +00:00
clear measurements
This commit is contained in:
parent
ab6ea575d7
commit
699c961b85
1 changed files with 40 additions and 22 deletions
|
|
@ -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"))
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue