颤动底部导航条垫两次用于键盘

问题描述 投票:2回答:2

BottomNavigationBar有问题,键盘启动时它会增加高度

Before

After focused on TextField

非常感谢对这个问题的见解。非常感谢你!

码:

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(),
    );
  }
}
android flutter bottomnavigationview
2个回答
2
投票

这看起来就像这个已知的问题。 https://github.com/flutter/flutter/issues/12084

如果有多个支架,则为每个支架添加一次填充物。


0
投票
Scaffold(
        ...
        resizeToAvoidBottomPadding: false,
        ...
}

试试这个。在我的情况下,键盘和输入字段之间有一个很大的空间。 (不完全相同,我的标签栏是正常的)

我通过设置此属性解决了它。我不知道它是否适合你的情况。祝好运!!

© www.soinside.com 2019 - 2024. All rights reserved.