D V Yogesh
D V Yogesh

Reputation: 3700

Flutter Row() 'crossAxisAlignment != CrossAxisAlignment.baseline || textBaseline != null': is not true. Failed assertion:

in flutter i am getting error while using crossAxisAlignment: CrossAxisAlignment.baseline

Error::

Failed assertion: line 3791 pos 15: 'crossAxisAlignment != CrossAxisAlignment.baseline || textBaseline != null': is not true.

code::

 Row(
    crossAxisAlignment: CrossAxisAlignment.baseline,

    children: <Widget>[
        Text(
            '192',
            style: kBoldNumberText,
        ),
        Text(
        'cm',
        style: kLabelText,
        )
    ],
    )

Upvotes: 13

Views: 7238

Answers (3)

Komron-Mirzo
Komron-Mirzo

Reputation: 21

In my case I also added textBaseline: TextBaseline.idiographic.

Here is the code:

Row(
  mainAxisAlignment: MainAxisAlignment.center,
  textBaseline: TextBaseline.ideographic,
  crossAxisAlignment: CrossAxisAlignment.baseline,
  children: const [
    Text(
      "190",
      style: kNumberTextStyle,
    ),
    Text(
      "cm",
      style: kIconTextStyle,
    ),
  ],
),

Upvotes: 0

Pratik Thorat
Pratik Thorat

Reputation: 513

I think you simply need to insert the following: textBaseline: TextBaseline.aplhabetic

In your case,

Row(
    crossAxisAlignment: CrossAxisAlignment.baseline,
    textBaseline: TextBaseline.alphabetic //here
    children: <Widget>[
        Text(
            '192',
            style: kBoldNumberText,
        ),
        Text(
        'cm',
        style: kLabelText,
        )
    ],
    )

Let me know if this helps you.

Upvotes: 1

D V Yogesh
D V Yogesh

Reputation: 3700

While using crossAxisAlignment in flutter we need to tell what element to align, for that we can use textBaseline: TextBaseline.alphabetic in alphabetic or if it is graphical

//alphabetic:::

textBaseline: TextBaseline.alphabetic,

-or-

//graphic:::

textBaseline: TextBaseline.ideographic

in my case its alphabetic::: so i re-write

Row(
    crossAxisAlignment: CrossAxisAlignment.baseline,
    textBaseline: TextBaseline.alphabetic, ////<-- HERE --> ////
    children: <Widget>[
        Text(
            '192',
            style: kBoldNumberText,
        ),
        Text(
        'cm',
        style: kLabelText,
        )
    ],
    )

Upvotes: 25

Related Questions