Is there a way to float a box from a Widget in the AppBar over (above) the Scaffold body? For example, if I put my search Widget into the Scaffold body, when my search IconButton is tapped, this TextField appears and hangs over the content below it:
However, ideally, I'd like the search icon to appear in the AppBar (not the Scaffold body), and then when tapped, I'd like the input box to float over the Scaffold body. If I put my Search Widget into the AppBar, the TextField is hidden under the Scaffold body, like this:
If you look carefully, you can actually see the TextField focusedBorder after I tap in the small margin below the icon on the AppBar but above the Scaffold body:
So, you can see that the TextField is hidden behind the Scaffold body.
I discovered from the Flutter documentation that the Scaffold body puts its content below the AppBar and behind the floatingActionButton and drawer by design (https://api.flutter.dev/flutter/material/Scaffold/body.html). However, using a floatingActionButton or a drawer for this use case would be a bit of a hack.
I suppose that I could have the TextField in a separate widget and located in the Scaffold body and use a Provider/ChangeNotifier to communicate to the widget in the Scaffold that the IconButton in the AppBar was tapped. But, that splits the component logic into two places, which seems messy.
I'm hoping someone can enlighten me with a best practice or set me in the right direction.
So, is there an appropriate way to have an IconButton in an AppBar display a TextField that floats over the Scaffold body? (It seems like it would be a common use case.)



