From c11e7b345b055bcfe55c080d93f1a9a402d3c926 Mon Sep 17 00:00:00 2001 From: Bhav Khurana <96694482+bhav-khurana@users.noreply.github.com> Date: Sat, 9 Dec 2023 21:59:05 +0530 Subject: [PATCH] Bug fix: Edited tag does not get updated immediately (#2224) --- .../after_auth_screens/add_post_page.dart | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/views/after_auth_screens/add_post_page.dart b/lib/views/after_auth_screens/add_post_page.dart index 78c7c0659..f9fec26bd 100644 --- a/lib/views/after_auth_screens/add_post_page.dart +++ b/lib/views/after_auth_screens/add_post_page.dart @@ -9,12 +9,17 @@ import 'package:talawa/views/base_view.dart'; late AddPostViewModel model; /// AddPost returns a widget to add(upload) the post. -class AddPost extends StatelessWidget { +class AddPost extends StatefulWidget { const AddPost({super.key, this.drawerKey}); /// DrawerKey. final GlobalKey? drawerKey; + @override + State createState() => _AddPostState(); +} + +class _AddPostState extends State { @override Widget build(BuildContext context) { // final Uint8List imageBytes = base64Decode(sampleBase64Image); @@ -100,15 +105,16 @@ class AddPost extends StatelessWidget { // button to add hastags to the post. TextButton( key: const Key('add_post_text_btn2'), - onPressed: () { - showDialog( + onPressed: () async { + final TextEditingController hashController = + TextEditingController(); + hashController.text = model.textHashTagController.text; + await showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: const Text("Enter the Tag"), - content: TextField( - controller: model.textHashTagController, - ), + content: TextField(controller: hashController), actions: [ TextButton( key: const Key("add_hashtag_button"), @@ -132,11 +138,14 @@ class AddPost extends StatelessWidget { ); }, ); + setState(() { + model.textHashTagController.text = hashController.text; + }); }, child: Text( model.textHashTagController.text == "" ? '# ${AppLocalizations.of(context)!.strictTranslate("Add tag")}' - : model.textHashTagController.text, + : '# ${model.textHashTagController.text}', style: Theme.of(context).textTheme.titleLarge, ), ),