AppBar Title粘贴在屏幕的左侧

时间:2017-10-08 14:00:12

标签: dart flutter

为什么标题贴在左边而不是留下一些空间?

这是脚手架代码

return new Scaffold(
        appBar: new AppBar(title: const Text('Friendlychat')),);

AppBar Title

3 个答案:

答案 0 :(得分:0)

您可以通过几种方法修改它:

您可以将title窗口小部件包装在Padding窗口小部件中,并使用padding属性缩进左侧区域。

enter image description here

@override
  Widget build(BuildContext context) {
    return new Scaffold(
        appBar: new AppBar(
          title: new Padding (child: new Text ("Friendly Chat"),
              padding:const EdgeInsets.only(left: 20.0) ),
        ),
    );
  }

或者您可以在Container的{​​{1}}媒体资源中添加空leading

AppBar

如果您希望标题居中,请将@override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( title:new Text ("Friendly Chat"), leading: new Container(), ), ); } 中的属性centerTitle设置为AppBar

enter image description here

true

答案 1 :(得分:0)

这是当前扑动的alpha版本中的回归,已在master中修复 - 请参阅此issue

目前,aziza的答案中提到的任何变通方法都可以使用,但是当新的alpha发布时你必须还原它

答案 2 :(得分:0)

这是当前扑动的alpha版本的回归,在@ aptik.Thanks指出

相关问题