Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This widget is not vertically Centered. #10

Open
aytunch opened this issue Apr 25, 2021 · 1 comment
Open

This widget is not vertically Centered. #10

aytunch opened this issue Apr 25, 2021 · 1 comment

Comments

@aytunch
Copy link

aytunch commented Apr 25, 2021

In the Build Method there is a SizedBox with Height = 1.5 * fontSize.
I have fontsize = 100, so my Height is 150pixels.
Inside of it there is a Row.
However when you wrap the whole widget in a Container and give color you can see that it is in the bottom of the container.
Could you implement a way to Center vertically?

@csells
Copy link

csells commented Sep 3, 2024

If you want to fork, I was able to solve this problem with the JumpingDotsProgressIndicator in the build method of the _JumpingDot widget:

class _JumpingDot extends AnimatedWidget {
  final Color color;
  final double fontSize;

  const _JumpingDot({
    required Animation<double> animation,
    required this.color,
    required this.fontSize,
  }) : super(listenable: animation);

  Animation<double> get _animation => listenable as Animation<double>;

  @override
  Widget build(BuildContext context) => SizedBox(
        height: _animation.value + fontSize,
        child: Text(
          '.',
          style: TextStyle(
            color: color,
            fontSize: fontSize,
            // Center the text vertically within its line height
            height: 1,
          ),
        ),
      );
}

The use of height: 1 forced the text to be centered vertically within its line height.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants