gpt4 book ai didi

flutter - Flutter中如何缩小AppBar的标题空间

转载 作者:IT王子 更新时间:2023-10-29 06:50:07 26 4
gpt4 key购买 nike

我已经在 AppBar 的构造函数中覆盖了 titleSpacing。但标题空间没有区别。

new AppBar(

backgroundColor: Colors.amber,
title: new Text("Flying Dutchman",
style: new TextStyle(
color: const Color(0xFF444444),
fontSize: 30.0,
fontWeight: FontWeight.w900,
),
),
titleSpacing: 0.00,
centerTitle: true,
elevation: 0.0,
)

enter image description here

我想减少应用栏标题的顶部空间。

最佳答案

titleSpacing 与实际的应用栏高度和顶部填充无关。它是水平轴上的间距。

AppBarmaterial 之后的预样式化组件规则。

如果您不喜欢这些规则,请不要一开始就使用 AppBar。去创建你自己的组件! :)

这是一个实现示例:

class MyAppbar extends StatelessWidget implements PreferredSizeWidget {
final String title;

const MyAppbar({this.title});

@override
Widget build(BuildContext context) {
return new Container(
color: Colors.amber,
height: preferredSize.height,
child: new Center(
child: new Text(title),
),
);
}

@override
Size get preferredSize => const Size.fromHeight(40.0);
}

关于flutter - Flutter中如何缩小AppBar的标题空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50239477/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com