TextBaseline的字母和表意枚举在Flutter中不起作用 [英] TextBaseline's alphabetic and ideographic enums do not work in Flutter

查看:146
本文介绍了TextBaseline的字母和表意枚举在Flutter中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以为我理解这些枚举如何基于此

I thought I understand how these enums work based on this post. When I tried it using the following code, it does not seem to work.

Row(
  mainAxisAlignment: MainAxisAlignment.center,
  crossAxisAlignment: CrossAxisAlignment.baseline,
  textBaseline: TextBaseline.ideographic,
  children: <Widget>[
    Text(
      'abcdefg',
      style: TextStyle(
          fontSize: 50.0, fontWeight: FontWeight.w900),
    ),
    Text(
      'hi',
      style: TextStyle(fontSize: 15.0),
    ),
  ],
),

但是,无论我选择用作文本基线(表意文字或无形文字),结果始终是相同的:

However, whatever I choose to use as text baseline (ideographic or aphabetic), the result is always the same:

我希望"hi"与"abcdefg"的表意基线对齐,而不是像这样按字母顺序对齐:

I expect that "hi" aligns to the ideographic baseline of "abcdefg", not to its alphabetic baseline like so:

我做错了什么?

Row小部件的上下文中,两者之间应该有所区别.我尝试删除行textBaseline: TextBaseline.ideographic,但出现此错误:

There should be a difference between the two in the context of Row widget. I tried removing the line textBaseline: TextBaseline.ideographic, I got this error:

'package:flutter/src/widgets/basic.dart': Failed assertion: line 3791 pos 15: 'crossAxisAlignment != CrossAxisAlignment.baseline || textBaseline != null': is not true.

要求使用哪个基线必须是Flutter知道要与哪个基线对齐的方式.

Requiring which baseline to use must be Flutter's way of knowing which baseline to align against.

推荐答案

截屏:

您不需要基线.

Row(
  mainAxisAlignment: MainAxisAlignment.center,
  crossAxisAlignment: CrossAxisAlignment.end,
  children: <Widget>[
    Text(
      'abcdefg',
      style: TextStyle(fontSize: 50.0, fontWeight: FontWeight.w900),
    ),
    Text(
      'hi',
      style: TextStyle(fontSize: 15.0),
    ),
  ],
)

这篇关于TextBaseline的字母和表意枚举在Flutter中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆