Flutter将应用栏标题向左偏移

时间:2019-08-09 20:54:17

标签: flutter

我正在为我的应用程序创建页面,并且已创建带有前导图标的应用程序栏。但是,图标和标题之间的空间非常大,对我来说,看起来很象样。

我确实将应用栏的标题向左偏移/稍微向左推。

代码:

appBar: AppBar(
    leading: Builder(
        builder: (BuildContext context) {
        return IconButton(
            icon: const Icon(Icons.chevron_left),
            iconSize: MediaQuery.of(context).size.width * 0.1,
            splashColor: Colors.transparent,
            highlightColor: Colors.transparent,
            padding: EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0),
            onPressed: () => Navigator.of(context).pop(),
        );
        },
    ),
    title: Text("Student Finance",
        style: TextStyle(color: Colors.white),
    ),
),

截屏:

enter image description here

1 个答案:

答案 0 :(得分:1)

///在标题小部件下添加所有内容,并使其前导为假

AppBar(
    title: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[  
            IconButton(
                onPressed: () => Navigator.pop(context),
                icon: const Icon(Icons.chevron_left, size: 32.0),
            ),
            Text("Student Finance"),
        ],
    ),
    titleSpacing: 0.0,
    automaticallyImplyLeading: false,
),