dartflutterflutter-layout

Is it possible to make characters in Flutter to have the same width?


As you can see in the picture below, the texts have the same amount of characters, but since the number "1" is slimmer than the "5" and "2", both texts get a different width.

How can I adjust that in Flutter?

's


Solution

  • You can set the font feature to use tabularFigures.

    // import 'dart:ui';
    
    Text(
      _getTimeString(),
      style: TextStyle(
        fontFeatures: [
          FontFeature.tabularFigures()
        ],
      ),
    ),
    

    Before:

    enter image description here

    After:

    enter image description here

    See also: