Disable Flutter text Baseline

4,026

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,
                  ),
Share:
4,026
Koen Van Looveren
Author by

Koen Van Looveren

Android developer @icapps

Updated on December 11, 2022

Comments

  • Koen Van Looveren
    Koen Van Looveren 11 months

    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);
    
  • Koen Van Looveren
    Koen Van Looveren over 4 years
    The border is not the problem that is pained by flutter for debugging. (text baselilnes)
  • user3249027
    user3249027 about 4 years
    ´height´ can't be set directly on the Text widget
  • UkFLSUI
    UkFLSUI over 3 years
    Generally, answers are much more helpful if they include an explanation of what the code is intended to do, and why that solves the problem without introducing others.
  • Sumit
    Sumit over 1 year
    Thanks, i am trying to do this for 10 different languages in 4 different fonts