'Animating AppBar like WhatsApp AppBar in Flutter

I wanted to know how to achieve the following animation. Where the Tabbar swipe animation is synced with The appBar(In WhatsApp).

Animation in Discussion

I am able to animate the AppBar. However not able to sync the animation with the swipe animation of the TabBar.

It would be great if someone can help me with it.

I am talking about the animation where the appbar hides by sliding up as we swipe the page to the side. I am able to add the animation of hiding the app by sliding up, however linking the page slide with the appbar slide. Is what i am looking for.

Thank You!



Solution 1:[1]

The TabBar widget has a default configuration to show this animation. Just initialize the indicator, indicatorSize and indicatorColor parameters.

TabBar(
  indicator: BoxDecoration(
    color: Color.fromRGBO(50, 51, 60, 1),
  ),
  labelColor: Colors.white,
  unselectedLabelColor: Colors.black,
  indicatorColor: Colors.black,
  indicatorSize: TabBarIndicatorSize.label,
  tabs: [],
),

Solution 2:[2]

I don't really understand the code you are showing or how it relates to the question in the title of your post. I'll just answer the question, which is:

How to make a for loop until a button is pressed

The answer is that you probably don't want to do that, because that would involve multi-threading or some kind of complicated concurrency mechanism. When you're writing a GUI, the main thread of your application usually sits in a loop waiting for event messages (like clicks and key presses) from the operating system. When it gets such a message, it is supposed to handle them quickly and then go back to waiting for the next message.

In Qt, you can handle these events by overriding functions in your QMainWindow class or by connecting Qt signals to slots.

So, instead of having a loop that iterates through each player and waits for them to make their move, you would have some long-living variables that keep track of the state of the game, and when you detect that a player has made a move (i.e. by clicking a button), you would update those variables, update any data shown on the screen, and then return from your event handler so you can handle the next event.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Furkan AbbasioÄŸlu
Solution 2 David Grayson