大家好,我正在尝试将自定义字体“Gill Sans”添加到我的移动应用程序中。然而,当我尝试将图标/图标按钮和文本对齐在同一行时,它们看起来非常不对齐。看来这种字体给默认的 flutter 字体的对齐带来了麻烦。
有人知道如何纠正对齐吗?谢谢
这就是它目前的样子,似乎文本太靠近顶部了。
这就是标准 flutter 字体的样子,以及我希望对齐的样子:
这是我正在使用的字体的链接。 Gill Sans 常规:
https://www.fontles.com/download/gill-sans-font/
这是我的代码的快照,使用简单的列表图块:
import 'package:flutter/material.dart';
void main() {
runApp(const MaterialApp(home: App()));
}
class App extends StatelessWidget {
const App({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Playground"),
centerTitle: true,
),
body: const ListTile(
leading: Icon(Icons.home),
minLeadingWidth: 0,
title: Text(
"Hello World",
style: TextStyle(
fontFamily: "Calibri",
),
),
),
);
}
}
我以前遇到过同样的问题,您可以尝试在 Text 小部件中添加
style
属性,并使用 height
属性 1 添加 TextStyle
const Text(
"Hello World",
style: TextStyle(height: 1),
)