Disable Flutter text Baseline

Viewed 4419

How can I disable the textbaseline?

enter image description here

because my text is not centered

enter image description here

I try to center a text in a contair. I use this font: https://www.dafont.com/young.font?l[]=10&l[]=1

import 'package:flutte_template/styles/theme_dimens.dart';
import 'package:flutter/material.dart';

class RoundedChip extends StatelessWidget {
  final Widget child;
  final Color color;

  const RoundedChip({@required this.child, @required this.color});

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 12, vertical: ThemeDimens.padding4),
        child: Row(
          mainAxisSize: MainAxisSize.min,
          children: [
            Padding(
             padding: const EdgeInsets.symmetric(vertical: ThemeDimens.padding4),
             child: Text('Drama', style: ThemeTextStyles.mediaDetailGenreText),
            ),
          ],
        ),
      ),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.all(
          Radius.circular(999),
        ),
        color: color,
      ),
    );
  }
}

  static const TextStyle mediaDetailGenreText = TextStyle(color: ThemeColors.textColor, fontSize: 15, fontWeight: FontWeight.w500);
4 Answers

I hope it helps after this long time :) wrap the text widget with baseline widget

Baseline(
                    baselineType: TextBaseline.alphabetic,
                    child: Text(
                      'Some Text',
                      textAlign: TextAlign.center,
                    ),
                    baseline: 40.0,
                  ),

Just add an inputDecoration with no input border to the textField like this:

TextField(
  decoration: InputDecoration(border: InputBorder.none),
)

Try TextDecoration.none, its work for me. ex: Text("Hello", style: TextStyle(fontSize: 12, decoration: TextDecoration.none),)

I think the issue is on the line height of the Font... You can tweak that value directly, is in percentage terms of the font size. So, try the values by eye: lets say:

Text( "Drama", height: 0.8 );
Related