-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add clear local storage button to settings view
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:excode/src/factory.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class ClearDialogWidget extends StatelessWidget { | ||
const ClearDialogWidget({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return AlertDialog( | ||
title: const Text('Clear local storage'), | ||
content: const Text( | ||
'This clears all the settings and code stored locally and reverts the app to defaults when reopened.\nAre you sure you want to do this?'), | ||
actions: [ | ||
ElevatedButton( | ||
onPressed: () async { | ||
try { | ||
await box.deleteFromDisk(); | ||
} finally { | ||
if (context.mounted) { | ||
Navigator.of(context).pop(); | ||
} | ||
} | ||
}, | ||
child: const Text('Confirm')), | ||
ElevatedButton( | ||
onPressed: () { | ||
if (context.mounted) { | ||
Navigator.of(context).pop(); | ||
} | ||
}, | ||
child: const Text('Cancel'), | ||
) | ||
], | ||
); | ||
} | ||
} |