Flutter Widget Cheat Sheet - Your Ultimate Guide To Building Stunning UI - The Tech Vate
Flutter Widget Cheat Sheet - Your Ultimate Guide To Building Stunning UI - The Tech Vate
2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
April 8, 2024
SHARE
Welcome to the ultimate Flutter widget cheat sheet! In this blog post,
I will share the Flutter widget cheat sheet that will help you
remember Flutter’s basic essential widgets. It will enhance your
Flutter development journey.
https://thetechvate.com/flutter-widget-cheat-sheet/ 1/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
Table of Contents
Scaffold:
Scaffold(
appBar: AppBar(
title: Text('My App'),
),
body: Center(
child: Text('Hello, Flutter!'),
),
)
Container:
https://thetechvate.com/flutter-widget-cheat-sheet/ 2/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
Container(
decoration: BoxDecoration(),
padding: EdgeInsets.all(8),
alignment: Alignment.center,
child: Text('Hello, Flutter!'),
)
Column:
A widget that sets up its children widgets vertically. Unless you wrap
it with a scrollable widget, scrolling is not possible.
Column(
children: [
Text('First item'),
Text('Second item'),
],
)
Row:
Row(
children: [
Text('First item'),
Text('Second item'),
],
)
Center:
https://thetechvate.com/flutter-widget-cheat-sheet/ 3/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
It is an align widget that centers its child widget and may adjust its
own size in response to the child’s dimensions
Center(
child: Text('Hello, Flutter!'),
)
Ink:
Ink(
child: InkWell(
onTap: () {
// Handle tap
},
child: Container(
width: 100,
height: 100,
color: Colors.blue,
child: Center(
child: Text('Tap me'),
),
),
),
)
Stack:
https://thetechvate.com/flutter-widget-cheat-sheet/ 4/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
Stack(
children: [
Container(
width: 200,
height: 200,
color: Colors.blue,
),
Positioned(
top: 50,
left: 50,
child: Text('Hello'),
),
Positioned(
bottom: 50,
right: 50,
child: Text('Flutter'),
),
],
)
Align:
Align(
alignment: Alignment.center,
child: Text('Centered Text'),
)
Padding:
Padding(
padding: EdgeInsets.all(20.0),
https://thetechvate.com/flutter-widget-cheat-sheet/ 5/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
Transform:
Transform.rotate(
angle: math.pi / 4,
child: Text('Rotated Text'),
)
Expanded:
Row(
children: [
Expanded(
child: Container(color: Colors.blue),
),
Expanded(
child: Container(color: Colors.green),
),
],
)
MediaQuery:
https://thetechvate.com/flutter-widget-cheat-sheet/ 6/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
Flexible:
A widget that adjusts its size to fit the available space based on the
flex factor.
Row(
children: [
Flexible(
flex: 2,
child: Container(color: Colors.blue),
),
Flexible(
flex: 1,
child: Container(color: Colors.green),
),
],
)
LayoutBuilder:
LayoutBuilder(
builder: (context, constraints) {
if (constraints.maxWidth > 600) {
return DesktopLayout();
} else {
return MobileLayout();
https://thetechvate.com/flutter-widget-cheat-sheet/ 7/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
}
},
)
AspectRatio:
AspectRatio(
aspectRatio: 16 / 9,
child: Container(color: Colors.blue),
)
FractionallySizedBox:
FractionallySizedBox(
widthFactor: 0.5,
heightFactor: 0.3,
child: Container(color: Colors.blue),
)
GestureDetector:
https://thetechvate.com/flutter-widget-cheat-sheet/ 8/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
GestureDetector(
onTap: () {
// Handle tap
},
child: Container(
color: Colors.blue,
child: Text('Tap me'),
),
)
InkWell:
A widget that provides a visual ink splash effect when tapped.
InkWell(
onTap: () {
// Handle tap
},
child: Container(
color: Colors.blue,
child: Text('Tap me'),
),
)
Draggable:
A widget that allows users to drag and move its child within the
parent widget.
Draggable(
child: Container(
width: 100,
height: 100,
color: Colors.blue,
child: Center(child: Text('Drag me')),
),
feedback: Container(
width: 100,
https://thetechvate.com/flutter-widget-cheat-sheet/ 9/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
height: 100,
color: Colors.blue.withOpacity(0.5),
child: Center(child: Text('Dragging')),
),
childWhenDragging: Container(),
)
CheckBox:
Checkbox(
value: _value,
onChanged: (value) {
setState(() {
_value = value;
});
},
)
ListView:
ListView(
children: [
ListTile(title: Text('Item 1')),
ListTile(title: Text('Item 2')),
],
)
https://thetechvate.com/flutter-widget-cheat-sheet/ 10/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
GridView:
GridView.count(
crossAxisCount: 2,
children: [
Text('Item 1'),
Text('Item 2'),
],
)
SingleChildScrollView:
SingleChildScrollView(
child: Text('Scroll me!'),
)
PageView:
A scrollable list of pages, where each page occupies the full screen.
PageView(
children: [
Container(color: Colors.blue),
Container(color: Colors.green),
],
)
CustomScrollView:
https://thetechvate.com/flutter-widget-cheat-sheet/ 11/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
CustomScrollView(
slivers: [
SliverAppBar(
title: Text('App Bar'),
floating: true,
expandedHeight: 200,
flexibleSpace: FlexibleSpaceBar(
background: Image.network('https://example.com/image.jp
),
),
SliverList(
delegate: SliverChildListDelegate([
ListTile(title: Text('Item 1')),
ListTile(title: Text('Item 2')),
]),
),
],
)
NestedScrollView:
NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsSc
return [
SliverAppBar(
title: Text('App Bar'),
floating: true,
pinned: true,
expandedHeight: 200,
flexibleSpace: FlexibleSpaceBar(
background: Image.network('https://example.com/image.
),
https://thetechvate.com/flutter-widget-cheat-sheet/ 12/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
),
];
},
body: ListView.builder(
itemCount: 100,
itemBuilder: (BuildContext context, int index) {
return ListTile(title: Text('Item $index'));
},
),
)
5. Text Widgets:
Text:
Text('Hello, Flutter!')
RichText:
RichText(
text: TextSpan(
text: 'Hello',
style: TextStyle(color: Colors.blue),
children: <TextSpan>[
TextSpan(text: ' Flutter', style: TextStyle(fontWeight: F
],
),
)
https://thetechvate.com/flutter-widget-cheat-sheet/ 13/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
SelectableText:
SelectableText('Selectable Text')
6. Image Widget:
Image.asset:
Image.asset('assets/image.png')
Image.network:
FadeInImage:
FadeInImage.assetNetwork(
placeholder: 'assets/placeholder.png',
https://thetechvate.com/flutter-widget-cheat-sheet/ 14/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
image: 'https://example.com/image.jpg',
)
CircleAvatar:
CircleAvatar(
backgroundImage: AssetImage('assets/avatar.png'),
radius: 50,
)
TextField:
TextField(
decoration: InputDecoration(
labelText: 'Enter your name',
),
)
Slider:
Slider(
value: _sliderValue,
https://thetechvate.com/flutter-widget-cheat-sheet/ 15/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
onChanged: (value) {
setState(() {
_sliderValue = value;
});
},
)
Switch:
Switch(
value: _value,
onChanged: (value) {
setState(() {
_value = value;
});
},
)
Elevated Button:
ElevatedButton(
onPressed: () {
// Handle button press
},
child: Text('Press Me'),
)
Text Button:
https://thetechvate.com/flutter-widget-cheat-sheet/ 16/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
TextButton(
onPressed: () {
// Handle button press
},
child: Text('Press Me'),
)
Outlined Button:
OutlineButton(
onPressed: () {
// Handle button press
},
child: Text('Press Me'),
)
FloatingAction Button:
FloatingActionButton(
onPressed: () {
// Handle button press
},
child: Icon(Icons.add),
)
Icon Button:
https://thetechvate.com/flutter-widget-cheat-sheet/ 17/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
IconButton(
icon: Icon(Icons.star),
onPressed: () {
// Handle button press
},
)
Conclusion:
From basic layout widgets like Scaffold , Container , Column , and Row to
more advanced widgets for responsiveness like Expanded , Flexible ,
and MediaQuery , we explored how to create visually appealing and
adaptable UIs.
https://thetechvate.com/flutter-widget-cheat-sheet/ 18/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
FAQ
Muhammad Naeem
Professional Flutter Developer
SHARE
More Posts
Best 10 Flutter Voice Assistant, TTS, STT, And ASR Packages:
Why They Matter For Your App
https://thetechvate.com/flutter-widget-cheat-sheet/ 19/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
Email Subscribe
B
ES
T
Flutter!
Grow your business three times faster!
https://thetechvate.com/flutter-widget-cheat-sheet/ 20/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
Grab it Now
Related Post
https://thetechvate.com/flutter-widget-cheat-sheet/ 21/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
https://thetechvate.com/flutter-widget-cheat-sheet/ 22/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
https://thetechvate.com/flutter-widget-cheat-sheet/ 23/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
START LEARNING
Privacy Policy
Quick Links
HOME
FLUTTER
STORE
ABOUT
CONTACT
https://thetechvate.com/flutter-widget-cheat-sheet/ 24/25
18.10.2024 18:51 Flutter Widget Cheat Sheet: Your Ultimate Guide to Building Stunning UI - The Tech Vate
Get In Touch
Email Us [email protected]
Follow Us
https://thetechvate.com/flutter-widget-cheat-sheet/ 25/25