I want to change the color of “name” in “Search by name” to Colors.red.shade900
. But the hintText field takes String
as input. Here is the code for this field:
TextField(
decoration: InputDecoration(
hintText: 'Search by name',
hintStyle: TextStyle(
fontSize: 16,
color: Colors.black.withOpacity(0.6),
fontWeight: FontWeight.w600,
),
prefixIcon: const Padding(
padding: EdgeInsets.only(left: 8),
child: Icon(
Icons.search,
size: 28,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
color: Colors.black.withOpacity(0.6),
width: 3,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
color: Colors.black.withOpacity(0.6),
width: 3,
),
),
),
style: const TextStyle(
fontSize: 16,
color: Colors.black,
fontWeight: FontWeight.w600,
),
),
I have achieved this in regular text:
Using this code:
Text.rich(
TextSpan(
children: [
const TextSpan(
text: 'Car ',
),
TextSpan(
text: carId,
style: TextStyle(
color: Colors.red.shade900,
),
),
],
style: const TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
),
),
)