import 'package:flutter/material.dart'; import 'key_storage.dart'; class DeleteKeyPairPage extends StatelessWidget { const DeleteKeyPairPage({super.key}); Future _deleteKeyPair(BuildContext context) async { final keyStorage = KeyStorage(); await keyStorage.deleteKeys(); ScaffoldMessenger.of(context).showSnackBar( const SnackBar( content: Text('The key pair has been deleted.'), ), ); Navigator.pop(context); } void _showConfirmationDialog(BuildContext context) { showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: const Text('Confirm Deletion'), content: const Text( 'Are you sure you want to delete the key pair? This action is irreversible.'), actions: [ TextButton( child: const Text('Cancel'), onPressed: () { Navigator.of(context).pop(); }, ), TextButton( child: const Text('Delete'), onPressed: () { Navigator.of(context).pop(); _deleteKeyPair(context); }, ), ], ); }, ); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.black, appBar: AppBar( title: const Text('Delete a Key Pair'), ), body: Center( child: ElevatedButton( onPressed: () { _showConfirmationDialog(context); }, child: const Text('Delete Key Pair'), ), ), ); } }