I have a DropdownButton in Flutter and i want to change the color of the selected option (see image). Default color is grey. I could not find a parameter of DropdownButton to change that. I tried selectedRowColor
in ThemeData but it does not affect that color. Is it possible to change that color?
Minimal reproducible example:
import 'package:flutter/material.dart';
main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
highlightColor: Colors.red,
),
home: MyHome(),
);
}
}
class MyHome extends StatefulWidget {
@override
State<StatefulWidget> createState() => _MyHomeState();
}
class _MyHomeState extends State<MyHome> {
List<String> options = ['A', 'B', 'C', 'D'];
String selectedOption;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: DropdownButton(
hint: Text('Please choose an option'),
value: selectedOption,
onChanged: (String newValue) {
setState(() {
selectedOption = newValue;
});
},
items: options.map((option) {
return DropdownMenuItem(
child: Text(option),
value: option,
);
}).toList(),
),
),
);
}
}