suffixText set at the right of the TextField's container by default.
Try below code with custom textfield with currency at right of the value with onTextChanged method.
class CTextField extends StatefulWidget {
@override
CTextFieldState createState() => CTextFieldState();
}
class CTextFieldState extends State<CTextField> {
TextEditingController controller = TextEditingController();
@override
void initState() {
super.initState();
controller.addListener(onTextChanged);
}
@override
void dispose() {
controller.removeListener(onTextChanged);
controller.dispose();
super.dispose();
}
void onTextChanged() {
String text = controller.text;
if (!text.endsWith(' T')) {
controller.value = TextEditingValue(
text: text.replaceAll(' T', '') + ' T',
selection: TextSelection.collapsed(offset: text.length + 4),
);
}
}
@override
Widget build(BuildContext context) {
return TextField(
controller: controller,
keyboardType: TextInputType.number,
decoration: InputDecoration(
labelText: 'Amount',
hintText: 'Value',
),
);
}
}
Another way with Container:
Container(
decoration: BoxDecoration(borderRadius: BorderRadius.circular(5)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
IntrinsicWidth(
child: TextField(
decoration: InputDecoration(
border: InputBorder.none,
hintText: '25',
),
),
),
Text(
'T',
)
],
),
Icon(Icons.arrow_right_sharp)
],
),
),
suffixTextto include trailing blank characters it would push the currency symbol to the left. It is a hack though. If I would have to fill out a form, I'd expect to see currency symbol on the right.