2

I'm developing a web app, where I'm trying to add a chat screen. I'm trying to use the floatingActionButton parameter and witching between FloatingActionButton and the ChatRoom and the user presses the FloatingActionButton.

The flow of the ChatRoom,

User taps on FloatingActionButton and opens ChatRoom

On Logingin to ChatRoom and user sees the ChatScreen

User closes the ChatRoom

On Reopening the ChatRoom user is again shown the validation screen

When I wasn't using this switching, ChatRoom maintained its state and on reopening, it showed the user the ChatScreen as expected.

Code

GetBuilder<HomeController>(
          id: 'updateChatRoomContainer',
          builder: (_controller) {
            return AnimatedContainer(
              curve: Curves.fastOutSlowIn,
              width: _controller.chatRoomWidth,
              height: _controller.chatRoomHeight,
              duration: const Duration(milliseconds: 600),
              child: GetBuilder<ThemeController>(builder: (_themeController) {
                return _controller.chatRoomOpen
                    ? Stack(
                          children: [
                            ChatRoom(),
                            ChatRoomActions(_controller)
                          ],
                    )
                    : IconButton(
                        onPressed: _controller.toggleChatRoom,
                        icon: const Icon(
                          Icons.chat,
                        ),
                      );
              }),
            );
          })
ASAD HAMEED
  • 2,296
  • 1
  • 20
  • 36

1 Answers1

0

You should perhaps look into using PageView and switch between different indexes. That will maintain your state for you.

  • I needed a stack there, not sure how would I replace that with `PageView`. Nevertheless, I have changed the logic in my statemanamgent controller that allowed me to achieve it. – ASAD HAMEED Feb 20 '22 at 14:17