From 11dfa13a0bf48c6f4c1bb30415311e14396e33e0 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Mon, 5 Aug 2024 13:58:20 -0400 Subject: [PATCH] wrap stateful alert dialog in StatefulBuilder to enable toggle updates --- ...onversation_bot_settings_chat_details.dart | 72 ++++++++++--------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_settings_chat_details.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_settings_chat_details.dart index 36a965301..32a6caf5d 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_settings_chat_details.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_settings_chat_details.dart @@ -118,44 +118,46 @@ class ConversationBotSettingsChatDetailsState final bool? confirm = await showDialog( context: context, builder: (BuildContext context) { - return AlertDialog( - title: Text( - L10n.of(context)!.botConfig, - ), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text(L10n.of(context)!.conversationBotStatus), - Switch( - value: addBot, - onChanged: (value) { - setState( - () => addBot = value, - ); - }, - ), - ], + return StatefulBuilder( + builder: (context, setState) => AlertDialog( + title: Text( + L10n.of(context)!.botConfig, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(L10n.of(context)!.conversationBotStatus), + Switch( + value: addBot, + onChanged: (value) { + setState( + () => addBot = value, + ); + }, + ), + ], + ), + ], + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(false); + }, + child: Text(L10n.of(context)!.cancel), + ), + TextButton( + onPressed: () {}, + child: Text( + L10n.of(context)! + .conversationBotConfigConfirmChange, + ), ), ], ), - actions: [ - TextButton( - onPressed: () { - Navigator.of(context).pop(false); - }, - child: Text(L10n.of(context)!.cancel), - ), - TextButton( - onPressed: () {}, - child: Text( - L10n.of(context)! - .conversationBotConfigConfirmChange, - ), - ), - ], ); }, );