I'm kinda new to Flutter and I'm building an app for a college project, but I'm having problems with this widget.
DropdownButton input value in white color
DropdownButton input value in black color
This is my DropdownButton code, it appears with the Hint in white color, but when I select an item the value in the button appears as black. If I change the DropdownButton color to white, then when the popup appears the background-color is white and so the font-color. This way I can't see the items, because they're the same color as the background.
class DropdownWidget extends StatelessWidget {
final IconData icon;
final IconData arrowIcon;
final String hint;
final List items;
final Stream stream;
final Function onChanged;
DropdownWidget({this.icon, this.arrowIcon, this.hint, this.items, this.stream, this.onChanged});
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: stream,
builder: (context, snapshot) {
print("Snapshot data -> ${snapshot.data}");
return InputDecorator(
child: DropdownButton(
icon: Icon( arrowIcon, color: Colors.white,),
hint: Text( hint, style: TextStyle(color: Colors.white),),
items: items.map((value) {
print("Valor do item $value");
return DropdownMenuItem(
value: value,
child: Text(value.runtimeType == int ? value.toString() : value, style: TextStyle(color: Colors.black),),
);
}).toList(),
onChanged: onChanged,
value: snapshot.data,
isExpanded: true,
style: TextStyle(
// color: Colors.black,
color: Theme.of(context).textSelectionColor,
fontSize: 18.0,
),
underline: Container(),
isDense: true,
),
decoration: InputDecoration(
icon: icon == null ? null : Icon(icon, color: Colors.white,),
hintText: hint,
hintStyle: TextStyle(color: Colors.white),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Theme.of(context).primaryColor)
),
contentPadding: EdgeInsets.only(
left: 5,
right: 0,
bottom: 24,
top: 30
),
errorText: snapshot.hasError ? snapshot.error : null,
),
);
}
);
}
}
What could I do to solve this? Is there a way to make the popup's background-color darker or just the value inside the button in a different color from the item's color?



