As we are not able to make widget like RichText/Text Span For styling TextFormField,
Can anyone help me out regarding this...
Now Getting:-
Expected Result:-
How we can achieve a result like this?
Step 1: Locate the MaterialApp widget. Step 2: Inside the MaterialApp, add the theme parameter with ThemeData class assigned. Step 3: Inside the ThemeData add the inputDecorationTheme parameter and then assign the InputDecorationTheme .
Hint is not available as its direct available attribute or function but it was under the decorations you can select in the menu you have. Under that you can find label and hint.
Try these two files I had same requirement.
Just add attribute isMandate: true
in CInputDecoration and use CTextField.
CTextField(
...
decoration: new CInputDecoration(
isMandate: true,
...
))
https://github.com/sumit1954/Flutter/blob/master/CInputDecorator.dart https://github.com/sumit1954/Flutter/blob/master/CTextField.dart
Simplest way, but not exactly equals:
TextField(
decoration: InputDecoration(
hintText: 'Ciao',
suffixText: '*',
suffixStyle: TextStyle(
color: Colors.red,
),
),
),
Or create a custom TextField
to use hint as Widget instead of String
You can use my two customized files:
TextFieldCustom(
hintText: Text.rich(
TextSpan(
text: 'FIRST NAME',
children: <InlineSpan>[
TextSpan(
text: '*',
style: TextStyle(color: Colors.red),
),
],
style: TextStyle(color: Colors.black54),
),
),
),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With