bottomNavigationBar: BottomAppBar(
color: Colors.white,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: TextField(
maxLines: 1,
decoration: InputDecoration(hintText: 'Tags', border: InputBorder.none),
),
),
elevation: 0,
),
Although the TextField for contents sticks to keyboard(Theres a TextField for contents in the body.), the BottomAppBar doesnt do.
I chose to use BottomAppbar to put a TextField on the bottom. Is it a bad way to do it?
I would not recommend using a TextField
in the bottom navigation bar, it is not thought to hold such elements.
What I would do instead is something like (:
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Colum(
children: [
// Your widgets
...
Spacer(),
TextField(
...
),
),
);
}
}
Here, Spacer
will push the TextField
to the bottom of the application. If you did not use a SingleChildScrollView
, you would get an overflow error since the keyboard would overlap the TextField
. However, with the SingleChildScrollView
the content will be made scrollable so there's no overlap.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.