In this Flutter post, we will discuss how to change Flutter icon size in Flutter apps. A proper example with step by step explanation will be provided to practically demonstrate how to customize the size of Flutter icon widget.
You will be able to customize Flutter icon size with easy, after you finish reading this post. So let’s get right into it.
What is Flutter Icon Size?
It is the size of Flutter icon widget. Let’s first see what the default size of Flutter icon is, then we’ll customize its size using a proper Flutter code example.
Default Flutter Icon Size
In order to visualize the default size of Flutter icon, we just have to define a simple Flutter icon widget. See below code:
Icon(Icons.email)
You can see that this is the default size of icon widget in Flutter. Let’s now give that icon a custom size.
Change Flutter Icon Size
For that, we have to use the size constructor of Flutter icon widget class. It takes a double(decimal value) but we can pass integer as well. To demonstrate its working, we’ll pass a value of 50 to that constructor. See below code:
Icon( Icons.email, size: 50 )
As you can see, the size of icon has changed successfully.
So this is how you can customize Flutter icon size in your own Flutter apps as well. Do use it and share your experience with us. Let me know if you still have any questions related to the customization of Flutter icon size. I’d be glad to answer all your questions.
The complete source code of the above implemented Flutter icon size is provided in the below block.
Custom Flutter Icon Size Implementation Source Code
import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @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> { bool showPassword = false; @override Widget build(BuildContext context) { return SafeArea( child: Scaffold( body: Center( child: Icon( Icons.email, size: 50, )))); } }
Conclusion
As a conclusion, hope you now have learned how to practically customized the Flutter icon size. Your valuable feedback would be well appreciated.
I would also want you to visit my other informative posts on Flutter app development and many more. Thank you for reading this post.