Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. class _MyPage2State extends State<MyPage2> {
  2. String dropdownValue = "One";
  3.  
  4. @override
  5. Widget build(BuildContext context) {
  6. return Scaffold(
  7. body: Center(
  8. child: DropdownButton<String>(
  9. value: dropdownValue,
  10. onChanged: (String newValue) {
  11. if (newValue == dropdownValue) {
  12. print("do nothing");
  13. } else {
  14. setState(() {
  15. dropdownValue = newValue;
  16. });
  17. }
  18. },
  19. items: <String>['One', 'Two', 'Free', 'Four']
  20. .map<DropdownMenuItem<String>>((String value) {
  21. return DropdownMenuItem<String>(
  22. value: value,
  23. child: Text(
  24. value,
  25. style: TextStyle(
  26. color: value == dropdownValue ? Colors.grey : Colors.black),
  27. ),
  28. );
  29. }).toList(),
  30. ),
  31. ),
  32. );
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement