Flutter Tutorial

How do you set an icon in Flutter?

Flutter icon

Code

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget{
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
     return MaterialApp(
       debugShowCheckedModeBanner: false,
       title: 'Flutter App',
       theme: ThemeData(
           primarySwatch: Colors.green,
           brightness: Brightness.dark,
       ),
       darkTheme: ThemeData(
           brightness: Brightness.light,
           primarySwatch: Colors.grey
       ),
       color: Colors.amberAccent,
       home: Scaffold(
         appBar: AppBar(
           centerTitle: true,
           backgroundColor: Colors.cyan,
           title: const Text(
               'Flutter Tutorial',
             style: TextStyle(
               color: Colors.white,
               fontWeight: FontWeight.w800,
             ),
           ),

         ),
         body: const MyHome(),
       )
     );
  }
}

class MyHome extends StatelessWidget{
  const MyHome({super.key});

  @override
  Widget build(BuildContext context) {
    return const Scaffold(
      body: Center(
        child: Icon(
          Icons.flutter_dash_rounded,
          size: 150,
          color: Colors.amber,),
      ),

    );
  }
}

OutPut

Flutter Icons

Another One

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget{
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
     return MaterialApp(
       debugShowCheckedModeBanner: false,
       title: 'Flutter App',
       theme: ThemeData(
           primarySwatch: Colors.green,
           brightness: Brightness.dark,
       ),
       darkTheme: ThemeData(
           brightness: Brightness.light,
           primarySwatch: Colors.grey
       ),
       color: Colors.amberAccent,
       home: Scaffold(
         appBar: AppBar(
           centerTitle: true,
           backgroundColor: Colors.cyan,
           title: const Text(
               'Flutter Tutorial',
             style: TextStyle(
               color: Colors.white,
               fontWeight: FontWeight.w800,
             ),
           ),

         ),
         body: const MyHome(),
       )
     );
  }
}

class MyHome extends StatelessWidget{
  const MyHome({super.key});

  @override
  Widget build(BuildContext context) {
    return const Scaffold(
      body: Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: <Widget>[
          Icon(
            Icons.favorite,
            color: Colors.pink,
            size: 80.0,
          ),
          Icon(
            Icons.audiotrack,
            color: Colors.green,
            size: 80.0,
          ),
          Icon(
            Icons.beach_access,
            color: Colors.blue,
            size: 80.0,
          ),
        ],
      )

    );
  }
}

OutPut

icon
Scroll to Top