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:flutter/material.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
|
@ -32,34 +33,51 @@ class _ProfilePageState extends State<ProfilePage> {
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> clearMeasurements() async {
|
||||||
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
prefs.clear();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text("Your profile"),
|
title: Text("Your profile"),
|
||||||
),
|
),
|
||||||
body: ListView.builder(
|
body: Column(
|
||||||
padding: const EdgeInsets.all(8),
|
children: [
|
||||||
itemCount: storedMeasurements.length,
|
ListView.builder(
|
||||||
itemBuilder: (BuildContext context, int index) {
|
physics: NeverScrollableScrollPhysics(),
|
||||||
return InkWell(
|
shrinkWrap: true,
|
||||||
child: ListTile(
|
padding: const EdgeInsets.all(8),
|
||||||
onTap: null,
|
itemCount: storedMeasurements.length,
|
||||||
leading: CircleAvatar(
|
itemBuilder: (BuildContext context, int index) {
|
||||||
backgroundColor: Colors.lightGreen,
|
return InkWell(
|
||||||
child: Text("${index + 1}"),
|
child: ListTile(
|
||||||
foregroundColor: Colors.white,
|
onTap: null,
|
||||||
),
|
leading: CircleAvatar(
|
||||||
title: Row(
|
backgroundColor: Colors.lightGreen,
|
||||||
children: <Widget>[
|
child: Text("${index + 1}"),
|
||||||
Expanded(child: Text(storedMeasurements[index]["date"]!)),
|
foregroundColor: Colors.white,
|
||||||
Expanded(child: Text(storedMeasurements[index]["bmi"]!)),
|
),
|
||||||
Expanded(child: Text(storedMeasurements[index]["bfp"]!)),
|
title: Row(
|
||||||
],
|
children: <Widget>[
|
||||||
),
|
Expanded(child: Text(storedMeasurements[index]["date"]!)),
|
||||||
),
|
Expanded(child: Text(storedMeasurements[index]["bmi"]!)),
|
||||||
);
|
Expanded(child: Text(storedMeasurements[index]["bfp"]!)),
|
||||||
},
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
clearMeasurements();
|
||||||
|
Navigator.pushNamed(context, CalculatorPage.routeName);
|
||||||
|
},
|
||||||
|
child: Text("Clear Measurements"))
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue