snap property Null safety
If snap and floating are true then the floating app bar will "snap" into view.
If snap is true then a scroll that exposes the floating app bar will trigger an animation that slides the entire app bar into view. Similarly if a scroll dismisses the app bar, the animation will slide the app bar completely out of view. Additionally, setting snap to true will fully expand the floating app bar when the framework tries to reveal the contents of the app bar by calling RenderObject.showOnScreen. For example, when a TextField in the floating app bar gains focus, if snap is true, the framework will always fully expand the floating app bar, in order to reveal the focused TextField.
Snapping only applies when the app bar is floating, not when the app bar appears at the top of its scroll view.
The following animations show how the app bar changes its scrolling behavior based on the value of this property.
- App bar with snap set to false:
- App bar with snap set to true:
- SliverAppBar for more animated examples of how this property changes the behavior of the app bar in combination with pinned and floating.
final bool snap;