h65wang / flutter-animated-counter

An implicit animation widget that flips from one number to another.

Home Page:https://pub.dev/packages/animated_flip_counter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Single text widgets having more width than single text widget

SimonVillage opened this issue · comments

commented

I wonder if there is a solution for this?

    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text("123,123,123", style: TextStyle(fontSize: 24)),
        Row(
          children: [
            Text("1", style: TextStyle(fontSize: 24)),
            Text("2", style: TextStyle(fontSize: 24)),
            Text("3", style: TextStyle(fontSize: 24)),
            Text(",", style: TextStyle(fontSize: 24)),
            Text("1", style: TextStyle(fontSize: 24)),
            Text("2", style: TextStyle(fontSize: 24)),
            Text("3", style: TextStyle(fontSize: 24)),
            Text(",", style: TextStyle(fontSize: 24)),
            Text("1", style: TextStyle(fontSize: 24)),
            Text("2", style: TextStyle(fontSize: 24)),
            Text("3", style: TextStyle(fontSize: 24)),
          ],
        ),
      ],
    );

IMG_268FDF42EC11-1

This is intentional. This package ensures all digits occupy the same width, so that when their values change, there won't be any horizontal shifting.

For example, typically number 1 is "skinnier" than number 2. This package makes sure 1 is padded to be the same width as 2, such that when 1 is animated into 2, its width doesn't need to change, and other digits around it aren't affected.

For your case, you can consider using a monospaced font.