Reputation: 21
Padding(
padding: const EdgeInsets.all(20),
child: TextFormField(
style: TextStyle(fontSize: 18),
decoration: InputDecoration(
labelText: 'Balance',
labelStyle: TextStyle(fontSize: 18),
prefixText: '\$',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
),
),
keyboardType: TextInputType.number,
validator: (input) =>
input.trim().isEmpty ? 'Required' : null,
onSaved: (input) {
_giftCardBalance = input;
},
initialValue: _giftCardBalance,
),
),
How can I change the color of just the dollar sign to black, but leave the rest of the placeholders in the text fields as gray? I have tried changing the hint color in the theme data, but that changes the color to black for all of the fields.
Upvotes: 1
Views: 272
Reputation: 7660
There is a prefixStyle
property of InputDecoration
. You can set it like this:
Padding(
padding: const EdgeInsets.all(20),
child: TextFormField(
style: TextStyle(fontSize: 18),
decoration: InputDecoration(
labelText: 'Balance',
labelStyle: TextStyle(fontSize: 18),
prefixText: '\$',
// Here we can define the style!
prefixStyle: TextStyle(
color: Colors.blue,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
),
),
keyboardType: TextInputType.number,
validator: (input) =>
input.trim().isEmpty ? 'Required' : null,
onSaved: (input) {
_giftCardBalance = input;
},
initialValue: _giftCardBalance,
),
),
Upvotes: 3