MOCKSTACKS
EN
Questions And Answers

More Tutorials









Flutter Icon


The icon widget allows you to quickly build icon widgets using a prebuilt list of material icons, available in the Icons class. You can specify the icon size and color.

Example - ‘icon’

This app simply displays 3 icons with different sizes and colors.
Source Code

import 'package:flutter/material.dart';
void main() => runApp(new IconApp());
class IconApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new HomeWidget(),
);
}
}
class HomeWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
Row row1 = Row(
mainAxisAlignment: MainAxisAlignment.center, // center horizontally
children: <Widget>[
const Icon(Icons.add),
const Text("Default size 24, default color black")
]);
Row row2 =
Row(mainAxisAlignment: MainAxisAlignment.center, // center horizontally
children: <Widget>[
const Icon(Icons.add, size: 48.0),
const Text("Specified ize 48, default color black")
]);
Row row3 =
Row(mainAxisAlignment: MainAxisAlignment.center, // center horizontally
children: <Widget>[
const Icon(Icons.add, size: 96.0, color: Colors.red),
const Text("Specified size 96, specified color red")
]);
return new Scaffold(
appBar: new AppBar(title: const Text("Icons")),
body: new Column(
mainAxisAlignment: MainAxisAlignment.center, // center vertically
children: <Widget>[row1, row2, row3]));
}
}


Conclusion

In this page (written and validated by ) you learned about Flutter Icon . What's Next? If you are interested in completing Flutter tutorial, your next topic will be learning about: Flutter Buttons.



Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue: mockstacks@gmail.com.


Share On:


Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using Mockstacks.com, you agree to have read and accepted our terms of use, cookies and privacy policy.