This widget should do the trick, alter the TextStyle to suit your needs and you might want to update text to be an int if you’re only going to deal with numbers!
import 'package:flutter/material.dart';
class PadString extends StatelessWidget {
final String text;
final int charCount;
final String padChar;
const PadString({
Key? key,
required this.text,
this.charCount = 4,
this.padChar = "0",
}) : super(key: key);
@override
Widget build(BuildContext context) {
var padCount = charCount - text.length;
return Row(
children: [
for (int i = 0; i < padCount; i++)
Text(
padChar,
style: const TextStyle(color: Colors.grey),
),
Text(
text,
style: const TextStyle(color: Colors.orange),
),
],
);
}
}
3
Answers
You can split them into two
Text
widgets. For example like this:Output:
This widget should do the trick, alter the TextStyle to suit your needs and you might want to update text to be an int if you’re only going to deal with numbers!