如何在 Flutter 左侧放置 AppBar 标题

7 flutter flutter-appbar

这是我的 AppBar Tittle 代码,但它不起作用

 Widget build(BuildContext context){
return new Scaffold(
  appBar: new AppBar(
    title: new Padding(
      padding: const EdgeInsets.only(left: 20.0),
      child: new Text("App Name"),
    ),
  ),
);}
Run Code Online (Sandbox Code Playgroud)

Pat*_*nus 14

将该centerTitle属性设置为 false。


Jay*_*ara 9

Transform 是用于在 xyz 维度中强制转换小部件的小部件。

return Scaffold(
        appBar: AppBar(
          centerTitle: false,
          titleSpacing: 0.0,
          title:  Transform(
              // you can forcefully translate values left side using Transform
              transform:  Matrix4.translationValues(-20.0, 0.0, 0.0),
              child: Text(
                "HOLIDAYS",
                style: TextStyle(
                  color: dateBackgroundColor,
                ),
              ),
            ),
        ),
      );
Run Code Online (Sandbox Code Playgroud)


小智 8

默认情况下,AppBar 标题位于中心位置。要使文本位于左侧,您应该将属性 centerTitle 设置为 false,如下所示:

Widget build(BuildContext context){
  return new Scaffold(
    appBar: new AppBar(
      centerTitle: false
      title: new Padding(
        padding: const EdgeInsets.only(left: 20.0),
        child: new Text("App Name"),
      ),
    ),
  );
}
Run Code Online (Sandbox Code Playgroud)


小智 6

在 AppBar中将centerTile属性设置为 false 和leadingWidth: 0


Nil*_*ara 5

只需将centerTile属性设置为false在 AppBar 小部件中。

 AppBar(
        ...
        centerTitle: false,
        title: Text("App Name"),
        ...
        )
Run Code Online (Sandbox Code Playgroud)