Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class _MyPage2State extends State<MyPage2> {
- String dropdownValue = "One";
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: Center(
- child: DropdownButton<String>(
- value: dropdownValue,
- onChanged: (String newValue) {
- if (newValue == dropdownValue) {
- print("do nothing");
- } else {
- setState(() {
- dropdownValue = newValue;
- });
- }
- },
- items: <String>['One', 'Two', 'Free', 'Four']
- .map<DropdownMenuItem<String>>((String value) {
- return DropdownMenuItem<String>(
- value: value,
- child: Text(
- value,
- style: TextStyle(
- color: value == dropdownValue ? Colors.grey : Colors.black),
- ),
- );
- }).toList(),
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement