- To Load Custom Fonts from app -> Project Name -> Right Click -> New -> Directory -> fonts
- Download the font you need in https://fonts.google.com/
- Paste the downloaded font in fonts folder.
- Open pubspec.yaml and refer the following documentation(i.e) https://flutter.dev/docs/cookbook/design/fonts#from-packages
- Finally Select Packages get
main.dart
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.teal,
body: SafeArea(
child: Column(
children: <Widget>[
CircleAvatar(
radius: 50.0,
backgroundColor: Colors.red,
backgroundImage: AssetImage('images/android_robo.png'),
),
Text(
'Android',
style: TextStyle(
fontFamily: 'Pacifico',
fontSize: 40.0,
color: Colors.teal.shade100,
fontWeight: FontWeight.bold),
),
Text(
'Flutter Developer',
style: TextStyle(
fontFamily: 'Source Sans Pro',
fontSize: 20.0,
color: Colors.white,
fontWeight: FontWeight.bold,
letterSpacing: 2.5),
),
],
),
),
),
);
}
}pubspec.yaml
name: mi_card
description: A new Flutter application.
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- images/android_robo.png
fonts:
- family: Pacifico
fonts:
- asset: fonts/Pacifico-Regular.ttf
- family: Source Sans Pro
fonts:
- asset: fonts/SourceSansPro-Regular.ttf
}- Material icons are delightful, beautifully crafted symbols for common actions and items which is both available for Android and IOS.
Read the Documentation using the below link
- https://api.flutter.dev/flutter/material/Icons-class.html
- https://material.io/resources/icons/?style=baseline
- https://www.materialpalette.com/
main.dart
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.teal,
body: SafeArea(
child: Column(
children: <Widget>[
CircleAvatar(
radius: 50.0,
backgroundColor: Colors.red,
backgroundImage: AssetImage('images/android_robo.png'),
),
Text(
'Android',
style: TextStyle(
fontFamily: 'Pacifico',
fontSize: 40.0,
color: Colors.teal.shade100,
fontWeight: FontWeight.bold),
),
Text(
'Flutter Developer',
style: TextStyle(
fontFamily: 'Source Sans Pro',
fontSize: 20.0,
color: Colors.white,
fontWeight: FontWeight.bold,
letterSpacing: 2.5),
),
Container(
color: Colors.white,
padding: EdgeInsets.all(10.0),
margin: EdgeInsets.symmetric(vertical: 10.0, horizontal: 25.0 ),
child: Row(
children: <Widget>[
Icon(
Icons.phone,
color: Colors.teal.shade900,
),
SizedBox(
width: 10.0,
),
Text(
'+919191919191',
style: TextStyle(
color: Colors.teal.shade900,
fontFamily: 'Source Sans Pro',
fontSize: 20.0,
),
)
],
),
),
Container(
color: Colors.white,
padding: EdgeInsets.all(10.0),
margin: EdgeInsets.symmetric(vertical: 10.0, horizontal: 25.0 ),
child: Row(
children: <Widget>[
Icon(
Icons.email,
color: Colors.teal.shade900,
),
SizedBox(
width: 10.0,
),
Text(
'androidpillars@gmail.com',
style: TextStyle(
color: Colors.teal.shade900,
fontFamily: 'Source Sans Pro',
fontSize: 20.0,
),
)
],
),
)
],
),
),
),
);
}
}- A material design card: a panel with slightly rounded corners and an elevation shadow.
- A card is a sheet of Material used to represent some related information, for example an album, a geographical location, a meal, contact details, etc.
Read the Documentation using the below link
main.dart
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.teal,
body: SafeArea(
child: Column(
children: <Widget>[
CircleAvatar(
radius: 50.0,
backgroundColor: Colors.red,
backgroundImage: AssetImage('images/android_robo.png'),
),
Text(
'Android',
style: TextStyle(
fontFamily: 'Pacifico',
fontSize: 40.0,
color: Colors.teal.shade100,
fontWeight: FontWeight.bold),
),
Text(
'Flutter Developer',
style: TextStyle(
fontFamily: 'Source Sans Pro',
fontSize: 20.0,
color: Colors.white,
fontWeight: FontWeight.bold,
letterSpacing: 2.5),
),
Card(
color: Colors.white,
margin: EdgeInsets.symmetric(vertical: 10.0, horizontal: 25.0 ),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: <Widget>[
Icon(
Icons.phone,
color: Colors.teal.shade900,
),
SizedBox(
width: 10.0,
),
Text(
'+919191919191',
style: TextStyle(
color: Colors.teal.shade900,
fontFamily: 'Source Sans Pro',
fontSize: 20.0,
),
)
],
),
),
),
Card(
color: Colors.white,
margin: EdgeInsets.symmetric(vertical: 10.0, horizontal: 25.0 ),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: <Widget>[
Icon(
Icons.email,
color: Colors.teal.shade900,
),
SizedBox(
width: 10.0,
),
Text(
'androidpillars@gmail.com',
style: TextStyle(
color: Colors.teal.shade900,
fontFamily: 'Source Sans Pro',
fontSize: 20.0,
),
)
],
),
),
)
],
),
),
),
);
}
}- ListTile widget is used to populate a ListView in Flutter.
- It contains title as well as leading or trailing icons.
Read the Documentation using the below link
- https://api.flutter.dev/flutter/material/ListTile-class.html
- https://api.flutter.dev/flutter/widgets/Column-class.html
- https://api.flutter.dev/flutter/material/Divider-class.html
main.dart
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.teal,
body: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
CircleAvatar(
radius: 50.0,
backgroundColor: Colors.red,
backgroundImage: AssetImage('images/android_robo.png'),
),
Text(
'Android',
style: TextStyle(
fontFamily: 'Pacifico',
fontSize: 40.0,
color: Colors.teal.shade100,
fontWeight: FontWeight.bold),
),
Text(
'Flutter Developer',
style: TextStyle(
fontFamily: 'Source Sans Pro',
fontSize: 20.0,
color: Colors.white,
fontWeight: FontWeight.bold,
letterSpacing: 2.5),
),
SizedBox(
height: 20.0,
width: 150.0,
child: Divider(
color: Colors.teal.shade100,
),
),
Card(
margin: EdgeInsets.symmetric(vertical: 10.0, horizontal: 25.0 ),
child: ListTile(
leading: Icon(
Icons.phone,
color: Colors.teal.shade900,
),
title: Text(
'+919191919191',
style: TextStyle(
color: Colors.teal.shade900,
fontFamily: 'Source Sans Pro',
fontSize: 20.0,
),
),
)
),
Card(
margin: EdgeInsets.symmetric(vertical: 10.0, horizontal: 25.0 ),
child: ListTile(
leading: Icon(
Icons.email,
color: Colors.teal.shade900,
),
title: Text(
'android@gmail.com',
style: TextStyle(
color: Colors.teal.shade900,
fontFamily: 'Source Sans Pro',
fontSize: 20.0,
),
),
)
),
],
),
),
),
);
}
}- A widget that expands a child of a Row, Column, or Flex so that the child fills the available space.
- Using an Expanded widget makes a child of a Row, Column, or Flex expand to fill the available space along the main axis (e.g., horizontally for a Row or vertically for a Column).
Read the Documentation using the below link
main.dart
import 'package:flutter/material.dart';
void main() {
return runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.red,
appBar: AppBar(
title: Text('Dicee'),
backgroundColor: Colors.red,
),
body: DicePage(),
),
),
);
}
class DicePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Row(
children: <Widget>[
Expanded(
flex: 2,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Image.asset('images/dice1.png'),
),
),
Expanded(
flex: 2,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Image(
image: AssetImage('images/dice1.png'),
),
),
),
],
),
),
),
);
}
}- Buttons are the graphical control element that provides a user to trigger an event such as taking actions, making choices, searching things, and many more.
- They can be placed anywhere in our UI like dialogs, forms, cards, toolbars, etc.
- We mainly used the following types -> Flat Button, Raised Button, Floating Button and Drop Down Button.
Read the Documentation using the below link
main.dart
import 'package:flutter/material.dart';
void main() {
return runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.red,
appBar: AppBar(
title: Text('Dicee'),
backgroundColor: Colors.red,
),
body: DicePage(),
),
),
);
}
class DicePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Row(
children: <Widget>[
Expanded(
flex: 2,
child: FlatButton(
onPressed: () {
print('Left Button is Clicked');
},
child: Image.asset('images/dice1.png'),
),
),
Expanded(
flex: 2,
child: FlatButton(
onPressed: () {
print('Right Button is Clicked');
},
child: Image(
image: AssetImage('images/dice1.png'),
),
),
),
],
),
),
),
);
}
}