Added bottom options and reset.
This commit is contained in:
parent
78618aed9a
commit
84aaf9c527
6 changed files with 125 additions and 10 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'core/api.dart';
|
||||
import 'login.dart';
|
||||
|
||||
class SettingsPage extends StatefulWidget {
|
||||
const SettingsPage({super.key});
|
||||
|
|
@ -72,6 +73,46 @@ class _SettingsPageState extends State<SettingsPage> {
|
|||
}
|
||||
),
|
||||
const Divider(height: 32),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Reset All Data'),
|
||||
content: const Text('Are you sure you want to reset all data?'),
|
||||
actions: <Widget>[
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
await prefs.clear();
|
||||
Navigator.pop(context);
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const LoginPage(),
|
||||
),
|
||||
);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.red,
|
||||
textStyle: const TextStyle(color: Colors.white),
|
||||
),
|
||||
child: const Text('Yes'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text('No'),
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
child: const Text('Reset All Data'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue