Use this very simple code to reproduce:
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(),
body: Center(
child: Container(
color: Colors.orange[200],
child: const Text(
'探索文本工王田甲乙丙丁一二三四口',
style: TextStyle(
fontSize: 24,
height: 1,
),
),
),
),
),
);
}
}
This is the screenshot when running the app:
As we can see, the text has two strange things:
- It has non-neglectable bottom paddings.
- It has negative top padding.
This is a problem, because with such, we cannot vertically make a text center-aligned. for example, a Center
will make the text "box" centered, but due to uneven padding, it will indeed be put higher than expected.
By the way, I have tested it on a iPhone and an android, so it seems not to be a problem of one specific font, but rather something intrinsic.