BottomNavigationBar有问题,键盘启动时它会增加高度
非常感谢对这个问题的见解。非常感谢你!
码:
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
bottomNavigationBar: new BottomNavigationBar(
items: <BottomNavigationBarItem>[
new BottomNavigationBarItem(icon: new Icon(Icons.all_inclusive), title: new Text("Hello"), backgroundColor: Colors.cyan),
new BottomNavigationBarItem(icon: new Icon(Icons.home), title: new Text("Hello"), backgroundColor: Colors.lightGreen),
],
),
appBar: new AppBar(
title: new Text(widget.title),
),
body: new TextField(),
);
}
}
这看起来就像这个已知的问题。 https://github.com/flutter/flutter/issues/12084
如果有多个支架,则为每个支架添加一次填充物。
Scaffold(
...
resizeToAvoidBottomPadding: false,
...
}
试试这个。在我的情况下,键盘和输入字段之间有一个很大的空间。 (不完全相同,我的标签栏是正常的)
我通过设置此属性解决了它。我不知道它是否适合你的情况。祝好运!!