MAD PR 4exp
MAD PR 4exp
Flutter Icons
An icon is a graphic image representing an application or any specific entity containing
meaning for the user. It can be selectable and non-selectable. For example, the company's logo
is non-selectable. Sometimes it also contains a hyperlink to go to another page. It also acts as a
sign in place of a detailed explanation of the actual entity.
Flutter provides an Icon Widget to create icons in our applications. We can create icons in
Flutter, either using inbuilt icons or with the custom icons. Flutter provides the list of all icons
in the Icons class. In this article, we are going to learn how to use Flutter icons in the
application.
Icon Widget Properties
Flutter icons widget has different properties for customizing the icons. These properties are
explained below:
Property Descriptions
icon It is used to specify the icon name to display in the application. Generally,
Flutter uses material design icons that are symbols for common actions
and items.
color It is used to specify the color of the icon.
size It is used to specify the size of the icon in pixels. Usually, icons have
equal height and width.
textDirection It is used to specify to which direction the icon will be rendered.
Flutter images
When you create an app in Flutter, it includes both code and assets (resources). An asset is a
file, which is bundled and deployed with the app and is accessible at runtime. The asset can
include static data, configuration files, icons, and images. The Flutter supports many image
formats, such as JPEG, WebP, PNG, GIF, animated WebP/GIF, BMP, and WBMP.Displaying
images is the fundamental concept of most of the mobile apps. Flutter has an Image widget
that allows displaying different types of images in the mobile application.
import 'package:flutter/material.dar:
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyIconPage(),
);
}
}
class MyIconPage extends StatefulWidget {
@override
_MyIconPageState createState() => _MyIconPageState();
}
class _MyIconPageState extends State<MyIconPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Flutter Icon Tutorial'),
),
body: Column(children: <Widget>[
//icon with label below it
Container(
padding: EdgeInsets.all(30),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Column(children: <Widget>[
Icon(
Icons.camera_front,
size: 70
),
Text('Front Camera'),
]),
Column(children: <Widget>[
Icon(
Icons.camera_enhance,
size: 70
),
Text('Camera'),
]),
Column(children: <Widget>[
Icon(
Icons.camera_rear,
size: 70
),
Text('Rear Camera'),
]),
]
),
)
],
)
);
}
}
Output:-
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Flutter Image Demo'),
),
body: Center(
child: Column(
children: <Widget>[
Image.network(
'https://static.javatpoint.com/tutorial/flutter/images/flutter-creating-android-
platform-specific-code3.png',
height: 400,
width: 250),
Text(
'It is an image displays from the given url.',
style: TextStyle(fontSize: 20.0),
)
],
),
),
),
);
}
}
Output
Conclusion:-