I've been playing with this for some time and can not get this working. Basically I've got bottom navigation bar and I want at the top of the bottom navigation bar fixed positioned container which stay there even if the keyboard is displayed. So far no matter what I tried the container ends up at the top of the keyboard when the keyboard is called. Here is my code where I ended up so far. Basically my last hope was to wrap it in Stack widget but that didn't work.
class HomeScreen extends StatefulWidget { static const String id = '/app'; final FirebaseUser user; HomeScreen({this.user});
@override _HomeScreenState createState() => _HomeScreenState(); }
class _HomeScreenState extends State<HomeScreen> { int _currentIndex
= 0; final List<Widget> _children = [Screen1(), Screen2()];
void bottomTabHandler(int index) {
setState(() {
_currentIndex = index;
}); }
@override Widget build(BuildContext context) {
return Scaffold(
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: _currentIndex,
onTap: bottomTabHandler,
items: [
BottomNavigationBarItem(
icon: Icon(Icons.receipt),
title: Text('Option1'),
),
BottomNavigationBarItem(
icon: Icon(Icons.receipt),
title: Text('Option2'),
),
BottomNavigationBarItem(
icon: Icon(Icons.add), title: Text('Option3')),
],
),
appBar: AppBar(
centerTitle: true,
title: Text('XXX'),
automaticallyImplyLeading: false,
),
endDrawer: AppbarDrawer(),
body: Stack(
children: <Widget>[
_children[_currentIndex],
Positioned(
bottom: 0,
child: Container(
width: 250,
height: 100,
color: Colors.blue,
),
),
],
),
);
}
}
I've got simple TextField at screen1 and this is what I get


If you want to make sure the Widgets don't get adjusted when the keyboard appears, you can use the resizeToAvoidBottomInset property of the Scaffold:
return Scaffold(
resizeToAvoidBottomInset: false,
body: Stack(
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With