diff --git a/app/lib/main.dart b/app/lib/main.dart index 7f067bd..e13064c 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -464,23 +464,14 @@ class SSHKeyList extends ChangeNotifier { } } -class KeepOrDeleteKey extends StatefulWidget { +class KeepOrDeleteKey extends StatelessWidget { final String sshKey; const KeepOrDeleteKey({super.key, required this.sshKey}); - @override - State createState() => _KeepOrDeleteKeyState(); -} - -class _KeepOrDeleteKeyState extends State { - bool _selectedForDeletion = false; - - bool get selectedForDeletion => _selectedForDeletion; - @override Widget build(BuildContext context) { - final key = widget.sshKey; + final key = sshKey; final isKeySelectedToKeep = context.select( (keylist) => keylist.isKeySelectedToKeep(key), ); @@ -504,7 +495,7 @@ class _KeepOrDeleteKeyState extends State { } var title = "Unnamed Key"; - final sshKeySplit = widget.sshKey.split(' '); + final sshKeySplit = sshKey.split(' '); if (sshKeySplit.length >= 3) { final potentialTitle = sshKeySplit.sublist(2).join(' '); if (potentialTitle != "") { @@ -522,7 +513,7 @@ class _KeepOrDeleteKeyState extends State { ), Padding( padding: EdgeInsets.fromLTRB(20, 0, 20, 20), - child: Text(widget.sshKey, style: TextStyle(fontSize: 15)), + child: Text(sshKey, style: TextStyle(fontSize: 15)), ), Padding( padding: EdgeInsets.fromLTRB(20, 0, 20, 20), @@ -531,26 +522,20 @@ class _KeepOrDeleteKeyState extends State { children: [ TextButton( onPressed: () { - setState(() { - _selectedForDeletion = true; - Provider.of( - context, - listen: false, - ).selectKeyForDeletion(widget.sshKey); - }); + Provider.of( + context, + listen: false, + ).selectKeyForDeletion(sshKey); }, style: buttonStyleDelete, child: Text('Select for Deletion'), ), TextButton( onPressed: () { - setState(() { - _selectedForDeletion = false; - Provider.of( - context, - listen: false, - ).keepKey(widget.sshKey); - }); + Provider.of( + context, + listen: false, + ).keepKey(sshKey); }, style: buttonStyleKeep, child: Text('Keep Key'),