How To Change Flutter Dropdown Icon Size

flutter dropdown icon size

Flutter dropdown icon size customization. In this article, I will be discussing and implementing how to change Flutter dropdown icon size. I will be explaining each and everything step by step using a proper Flutter example code so you can have a better idea of how to change Flutter dropdown icon size. So without wasting anymore of your time, let’s just get right into changing the Flutter dropdown icon size.

What is Flutter Dropdown Icon Size?

Flutter dropdown icon size is the size of icon that you can see by default in the right side of the Flutter dropdown. In this post, we will change the size of this icon. Let’s start implementing it using proper Flutter example code.

Default Flutter Dropdown Icon Size

Let’s first see the default icon size of the Flutter dropdown button. For that we have defined a simple Flutter dropdown having two dropdown menu items. See the below code:

DropdownButton(
            borderRadius:
                BorderRadius.circular(20).copyWith(topLeft: Radius.circular(0)),
            isExpanded: true,
            hint: Text('Default icon size', style: TextStyle(fontSize: 15)),
            value: categoryValue,
            items: [
              DropdownMenuItem(
                  value: 'Sports',
                  child: Text('Sports',
                      style: TextStyle(fontSize: 15, color: Colors.black45))),
              DropdownMenuItem(
                  value: 'Tech',
                  child: Text('Tech',
                      style: TextStyle(fontSize: 15, color: Colors.black45))),
            ],
            onChanged: (val) {
              setState(() {
                categoryValue = val.toString();
              });
            })

flutter dropdown default icon size

You can see in this image the default Flutter dropdown icon size.

Change Flutter Dropdown Icon Size

To change the Flutter dropdown icon size, we have to use the icon size constructor of the Flutter dropdown button widget. For demonstration, I have given it a value of 30, it takes a double value so you can also give a decimal value like 30.5 etc. See the below code:

 iconSize: 30
flutter dropdown icon size
In the image, you can see that the Flutter dropdown icon size is now changed and it looks bigger than the default size of Flutter dropdown icon.
So in this way you can change the Flutter dropdown icon size, making it bigger or smaller depending on the requirements of your Flutter app project. If you have any questions regarding Flutter dropdown icon size customization then do let me know in the comment section. I would love to clear your doubts.
Now as a treat, I have designed a beautiful custom Flutter dropdown design for you in which Flutter dropdown icon size is also changed. The complete source code of this design is given in the next section.

Beautiful Flutter Dropdown Design Source Code

flutter dropdown icon size

import 'package:flutter/material.dart';
void main() {
  runApp(MyApp());
}
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Homepage(),
    );
  }
}
class Homepage extends StatefulWidget {
  @override
  State<Homepage> createState() => _HomepageState();
}
class _HomepageState extends State<Homepage> {
  String? categoryValue;
  @override
  Widget build(BuildContext context) {
    return SafeArea(
        child: Scaffold(
            body: Center(
                child: Padding(
      padding: EdgeInsets.all(20),
      child: Container(
        padding: EdgeInsets.symmetric(horizontal: 20, vertical: 5),
        decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(50).copyWith(
                bottomRight: Radius.circular(0), topLeft: Radius.circular(0)),
            color: Colors.blue.shade100),
        child: DropdownButtonHideUnderline(
          child: DropdownButton(
              iconSize: 30,
              borderRadius: BorderRadius.circular(20)
                  .copyWith(topLeft: Radius.circular(0)),
              isExpanded: true,
              hint: Text('Custom icon size', style: TextStyle(fontSize: 15)),
              value: categoryValue,
              items: [
                DropdownMenuItem(
                    value: 'Sports',
                    child: Text('Sports',
                        style: TextStyle(fontSize: 15, color: Colors.black45))),
                DropdownMenuItem(
                    value: 'Tech',
                    child: Text('Tech',
                        style: TextStyle(fontSize: 15, color: Colors.black45))),
              ],
              onChanged: (val) {
                setState(() {
                  categoryValue = val.toString();
                });
              }),
        ),
      ),
    ))));
  }
}

Conclusion

In conclusion, now you have a practical understanding of how to change Flutter dropdown icon size in Flutter dropdown. I would love to have your thoughts on this article. I also have written other amazing articles related to Flutter app development, Flutter widgets, Flutter animations, Flutter amazing templates and many more, links to some of these posts are listed below. Thanks for reading.

Leave a Comment

Your email address will not be published.