The Wayback Machine - https://web.archive.org/web/20240930214507/https://www.geeksforgeeks.org/icon-class-in-flutter/
Open In App

Icon Class in Flutter

Last Updated : 15 Feb, 2021
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Icon class in Flutter is used to show specific icons in our app. Instead of creating an image for our icon, we can simply use the Icon class for inserting an icon in our app. For using this class you must ensure that you have set uses-material-design: true in the pubsec.yml file of your object.

Syntax:
Icon(
      key key,
      size,
      color,
      semanticLabel,
      textDirection
)

Properties:

  • color: It is used to set the color of the icon
  • size: It is used to resize the Icon
  • semanticLable: It comes in play while using the app in accessibility mode (ie, voice-over)
  • textDirection: It is used for rendering Icon

Note: The semanticLabel are not visible in the UI.

A few of them are depicted below:

To view, the complete list of Icons click here.

Let’s see some of those icons in action with simple flutter apps.

Example: 

Here we will design an app that shows various icons on different tabs. Here we will have 5 tabs with 5 icons each and we will alter its properties to view the UI changes. The property changes are as below:

  1. music_note Icon:
    properties:
    color: default, size: 100, semanticLabel: None, textdirection: default
  2. music_video Icon:
    properties:
    color: default, size: 100, semanticLabel: None, textdirection: default
  3. camera_alt Icon:
    properties:
    color: default, size: 100, semanticLabel: 'Camera', textdirection: default
  4. grade Icon:
    properties:
    color: red, size: 300, semanticLabel: 'Star', textdirection: default
  5. email Icon:
    properties:
    color: default, size: default, semanticLabel: None', textdirection: default

Dart




import 'package:flutter/material.dart';
  
void main() {
  runApp(TabBarDemo());
}
  
class TabBarDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: DefaultTabController(
        length: 5,
        child: Scaffold(
          appBar: AppBar(
            bottom: TabBar(
              tabs: [
                Tab(icon: Icon(Icons.music_note)),
                Tab(icon: Icon(Icons.music_video)),
                Tab(icon: Icon(Icons.camera_alt)),
                Tab(icon: Icon(Icons.grade)),
                Tab(icon: Icon(Icons.email)),
              ],
            ),
            title: Text('GeeksForGeeks'),
            backgroundColor: Colors.green,
          ),
          body: TabBarView(
            children: [
              Icon(Icons.music_note,
                  size: 100),
              Icon(Icons.music_video,
                color: Colors.blue,
                size: 100),
              Icon(Icons.camera_alt,
                semanticLabel: 'Camera',
                size: 100),
              Icon(Icons.grade,
                color: Colors.red,
                size: 300,
                semanticLabel: 'Star',),
              Icon(Icons.email),
            ],
          ),
        ),
      ),
    );
  }
}


Output:



Previous Article
Next Article

Similar Reads

Flutter - Extended Icon Button
In Flutter there are many prebuilt Button - Material Button, Text Button, Elevated Button, etc. In this article, we are going to implement the Extended Icon Button, which can be customized as per user need. We can give color to the button. A sample video is given below to get an idea about what we are going to do in this article. [video mp4="https:
2 min read
Flutter - Prefix and Suffix Icon in TextField
In this article, we will implement how to add prefix and Suffix icons in the TextField. A sample image is given below to get an idea about what we are going to do in this article. Step by Step Implementation Step 1: Create a New Project in Android Studio To set up Flutter Development on Android Studio please refer to Android Studio Setup for Flutte
2 min read
Flutter - Circular Icon Button
In this article, we will implement how to make a circular icon button in Flutter. A sample image is given below to get an idea about what we are going to do in this article. Step by Step Implementation Step 1: Create a New Project in Android Studio To set up Flutter Development on Android Studio please refer to Android Studio Setup for Flutter Deve
2 min read
Flutter - Changing App Icon
Flutter SDK is an open-source software development kit for building beautiful UI which is natively compiled. When we create a Flutter Project, it comes with the default Flutter icon. In order to get the app published in stores like Google Play Store, Apple App Store, etc the default icon can be changed.  In this article, we will look into a few pos
3 min read
Is Flutter Worth Learning? Top 7 Reasons to Learn Flutter
In today's era, the usage of smartphones has increased exponentially and so has the use of mobile applications and websites. Meanwhile, considering future career prospects, learning web development and mobile app development is strongly recommended for all individuals. And when we come to mobile app development, there are two most-popular open-sour
5 min read
Flutter - Sharing Data Among Flutter Pages
In this article, we are going to find the solution for the problem statement "Import/send data from one page to another in flutter". Before going into the topic, there are some pre-requisites. Pre-requisites:Basics of dart programming language.Setting up Flutter in VS code or Setting up Flutter in Android Studio.Creating first flutter app | Hello W
4 min read
Flutter Quill - Rich Text Editor in Flutter Application
This post will explain how to integrate a rich text editor into your Flutter application so that it may enable rich text editing. There are many more things we can do with Flutter Quill, but they can get a little involved. The example below is a pretty basic demonstration of what we mean. Let's first discuss what flutter quill is and why we need it
5 min read
Flutter - Animated AlertDialog in Flutter
Animating an AlertDialog in Flutter involves using the Flutter animations framework to create custom animations for showing and hiding the dialogue. In this article, we are going to add an animation to an AlertDialog. A sample video is given below to get an idea about what we are going to do in this article. [video mp4="https://media.geeksforgeeks.
4 min read
Flutter - Different Types of Loading using Flutter EasyLoading
Flutter applications involve incorporating loading indicators to provide users with feedback during background operations. Flutter has a package for simplifying the process named flutter_easyloading package. This package easiest way to integrate loading indicators with various styles. In this article, we will implement different types of loading in
5 min read
Flutter - ColoredBox Class Widget
A Colored Box is a container that fills it with color according to its child or A widget that paints its area with a specified Color and then draws its child on top of that color. A sample image is given below to get an idea about what we are going to do in this article. How to use it? You can simple use this widget anywhere in your project as you
3 min read
Container class in Flutter
Container class in flutter is a convenience widget that combines common painting, positioning, and sizing of widgets. A Container class can be used to store one or more widgets and position them on the screen according to our convenience. Basically, a container is like a box to store contents. A basic container element that stores a widget has a ma
6 min read
Raised Button Class in Flutter Material Library with Example
Raised button class comes with a slight elevation in its structure on tapping by the user. They have several properties like text color, shape, padding, button color, etc. These are rectangular in shape by default which cannot be altered and have UI along their z-axis. It is a deprecated class, and an elevated button is preferred over raised button
4 min read
ListView Class in Flutter
In Flutter, ListView is a scrollable list of widgets arranged linearly. It displays its children one after another in the scroll direction i.e, vertical or horizontal. There are different types of ListViews : ListViewListView.builderListView.separatedListView.customConstructor of ListView Class:ListView( {Key key, Axis scrollDirection: Axis.vertica
5 min read
Flutter - PhotoHero Class
In Flutter, a Hero Widget is used to create a hero animation. A hero in this context refers to a widget that moves in between screens. This is one of the most fundamental types of animation used in the application, especially if the app deals with media like images. Simply put, a hero animation is when a hero flies from one screen to another. The P
3 min read
Expanded Class in Flutter
When we create any child of a row or column we provide the size of the widget according to the screen size but sometimes when we provide more size of child as compared to screen size we get a warning and our widget goes out of the screen for resolving this we put a child of a row or column in an expanded widget so that the child occupies only the a
5 min read
Flutter - BottomSheet Class
Bottom Sheet is one of the popular ways to show various options on the screen. This helps the user to switch to a new screen. You will see this bottom sheet in most of the app to add data or add some information such as address or ticket number. In this article, we are going to see how to implement the Bottom Sheet in our Flutter App. Constructor o
7 min read
FlatButton Class in Flutter Material Library with Example
Flutter FlatButton Class has been officially deprecated and should not be used. We can use TextButton class instead to achieve the same results. In the example below we have code that uses the TextButton class to achieve the same results as that of its deprecated counterpart (i.e. FlatButton). FlatButton class comes with a simple text button class
5 min read
Popping Button Class in Flutter Material Library with Example
A popping menu button is a widely used category of widgets that displays additional features to the user. They are generally used in the AppBar of the application for a quick menu option. The user is allowed to select from the provided options or navigate to a different screen based on his choice. To trigger the popup menu, a user has to press the
6 min read
FloatingActionButton Class in Flutter Material Library with Example
The Floating Action Button is the most unique type of button widget provided in flutter. It is a widget that floats on the screen over other widgets. It appears as a circular icon on the screen with an icon in its center as its child. It is by default placed at the bottom-right corner of the screen. To be able to use a floating action button in you
4 min read
Flutter Material Widget - Outlined Button Class
Outlined Widgets are material design components that are used to give outlines to buttons. It is in no way different from text buttons except for the special feature of the border this class provides. These contain nonprimary actions for the apps. It is introduced in version 1.22 of flutter. Outlined buttons have child as their label with text widg
4 min read
IconButton Class in Flutter with Example
The most different button class provided in flutter is the IconButton Class. In this tutorial, we will walk you through the implementation and properties of the IconButton class for flutter in detail. An icon button allows users to take actions like searching, navigation, adding, etc, by simply pressing the button. This class does not have a regula
4 min read
TextButton Class in Flutter Material Library with Examples
Text Button Class in flutter are material component button widgets with no border by default. It is just a regular button with some text written as the label. TextButton class is a replacement for the deprecated FlatButton class. It is undeprecated and performs all the functions of a FlatButton. To use a TextButton, you need to import the material
5 min read
Flutter - Edge Insets Class
Edge Insets are used for an offset from each of the four sides of a box. For example, the padding inside a box can be represented using this class. Edge Insets can give offset using different methods. In simple words, edge insets are used for padding the widget in Flutter. Typically Edge Insets have four methods - EdgeInsets.all, EdgeInsets.only, E
3 min read
Flutter Hooks - An Alternative to StatefulWidget Class
Flutter Hooks is a package that was introduced in Flutter v1.9 and provides an alternative way to manage state and other side effects in Flutter. Instead of using traditional stateful widgets, hooks allow you to use functional components to manage state and other side effects. In this article, we will explore how to use Flutter hooks to improve you
8 min read
Flutter - Convert JSON to Model Class in Dart
Many times you are receiving API data but it is difficult to create a model class manually for some data that are too big. So we can make a model with just 2 steps. Let's take sample data for which we want to create a model class. { "userId": 1, "id": 1, "title": "delectus aut autem", "completed": false }Step-by-Step Implementation Step 1: Just Cop
2 min read
CarouselView class in Flutter
A CarouselView widget in Flutter is an advanced widget that helps developers to design a list of widgets where only one item is visible as a carousel and can be implemented to cycle through images, items, product cards or content sliders, among others. In this article, more focus is given to the properties and possible ways of using the CarouselVie
4 min read
Scaffold class in Flutter with Examples
Scaffold is a class in flutter which provides many widgets or we can say APIs like Drawer, Snack-Bar, Bottom-Navigation-Bar, Floating-Action-Button, App-Bar, etc. Scaffold will expand or occupy the whole device screen. It will occupy the available space. The Scaffold will provide a framework for implementing the basic material design layout of the
7 min read
MaterialApp class in Flutter
MaterialApp Class: MaterialApp is a predefined class or widget in a flutter. It is likely the main or core component of a flutter app. The MaterialApp widget provides a wrapper around other Material Widgets. We can access all the other components and widgets provided by Flutter SDK. Text widget, DropdownButton widget, AppBar widget, Scaffold widget
7 min read
Expandable Widget in Flutter
The expandable widgets do not have a fixed size, they expand on the screen according to the available areas on the screen. Due to size constraints, certain widgets can throw rendering errors, so widgets are made expandable. The one use of expandable widgets is cards that include images, texts, and to further read the text we can click "Read More" o
3 min read
Flutter - Mark as Favorite Feature
Adding to favorites is a prevalent feature in many applications. It enables the users to mark or save images, addressed, links or others stuff for easy future reference. In this article, we are going to see how to implement favorites or add to favorites feature in a flutter application. This article list two methods to do so. In the first method, w
9 min read