Flutter Widget Guidance
Welcome to the Flutter Widget Guide! In this guide, you will find examples of various widgets along with their use cases. Flutter is a powerful UI toolkit, and understanding different widgets and their purposes is essential for building great mobile applications.
Table of Contents
Basic Widgets
Text and Images
Input and Form Widgets
List Widgets
Navigation and Routing Widgets
Animation Widgets
Layout Widgets
Image and Icon Handling
Material Design Widgets
Cupertino Design Widgets
Other Important Widgets
Basic Widgets
Container
Purpose: A box that can contain other widgets and style them using properties like color, padding, margin, and borders.
Row
Purpose: A widget that arranges its children widgets in a horizontal line.
Column
Purpose: A widget that arranges its children widgets in a vertical line.
Center
Purpose: A widget that centers its child widget within itself.
Expanded
Purpose: A widget that expands to fill the available space within a parent widget.
Padding
Purpose: A widget that adds padding around its child widget.
ListView
Purpose: A scrollable list of widgets that can be displayed vertically or horizontally.
GridView
Purpose: A scrollable grid of widgets that can be displayed in a 2D layout.
Stack
Purpose: A widget that overlays its children widgets on top of each other.
Positioned
Purpose: A widget that positions its child widget at a specific position within a Stack.
Text and Images
Text
Purpose: A widget that displays a piece of text.
RichText
Purpose: A widget that displays a paragraph of mixed-style text.
Image
Purpose: A widget that displays an image from the local assets or the internet.
Icon
Purpose: A widget that displays a material design icon.
Placeholder
Purpose: A widget that displays a box with a specified width, height, and color.
Tooltip
Purpose: A widget that shows a short message when the user long-presses on it.
Input and Form Widgets
TextField
Purpose: A widget that allows users to enter text.
TextFormField
Purpose: A more advanced version of TextField that is used within a Form widget.
RaisedButton
Purpose: A widget that displays a button with a raised appearance.
FlatButton
Purpose: A widget that displays a flat button.
IconButton
Purpose: A widget that displays a button with an icon.
Checkbox
Purpose: A widget that allows users to select multiple options from a list.
Radio
Purpose: A widget that allows users to select a single option from a list.
Slider
Purpose: A widget that allows users to select a value from a range of values.
Switch
Purpose: A widget that allows users to toggle between two states.
List Widgets
ListView
Purpose: A scrollable list of widgets that can be displayed vertically or horizontally.
ListTile
Purpose: A widget that displays a single fixed-height row with a leading icon, title, and subtitle.
GridView
Purpose: A scrollable grid of widgets that can be displayed in a 2D layout.
SliverGrid
Purpose: A grid with slivers that can be used with CustomScrollView.
ExpansionTile
Purpose: A widget that displays a tile that can be expanded or collapsed to reveal hidden content.
ListView.builder
Purpose: A more efficient way to create a ListView with a large number of children.
GridView.builder
Purpose: A more efficient way to create a GridView with a large number of children.
Navigation and Routing Widgets
MaterialApp
Purpose: A widget that sets up the necessary material design elements for an app.
Scaffold
Purpose: A widget that provides a basic structure for implementing material design components.
AppBar
Purpose: A widget that displays an app bar with a title and optional actions.
BottomNavigationBar
Purpose: A widget that displays a bottom navigation bar.
Drawer
Purpose: A widget that displays a side drawer that can be shown by swiping from the left or right.
Navigator
Purpose: A widget that manages a stack of pages and transitions between them.
MaterialPageRoute
Purpose: A class that defines a basic page route that transitions to a new page.
CupertinoPageRoute
Purpose: A class that defines a page route that provides a cupertino-style transition.
Animation Widgets
AnimatedContainer
Purpose: A container that automatically animates its changes when the properties change.
AnimatedCrossFade
Purpose: A widget that cross-fades between two children when switching between them.
Hero
Purpose: A widget that animates the shared transition of its tag with another Hero widget.
AnimatedBuilder
Purpose: A widget that rebuilds when given an Animation object.
SlideTransition
Purpose: A widget that animates the position of its child from an initial offset to an end offset.
FadeTransition
Purpose: A widget that animates the opacity of its child.
RotationTransition
Purpose: A widget that animates the rotation of its child.
Layout Widgets
SizedBox
Purpose: A box with a fixed width and height.
Flexible
Purpose: A widget that takes up available space and shares it with other flexible widgets.
Wrap
Purpose: A widget that wraps its children to the next line when there is insufficient space.
AspectRatio
Purpose: A widget that attempts to size the child to a specific aspect ratio.
ConstrainedBox
Purpose: A widget that imposes constraints on its child.
FittedBox
Purpose: A widget that scales and positions its child within itself.
Image and Icon Handling
Image
Purpose: A widget that displays an image from the local assets or the internet.
ImageIcon
Purpose: A widget that displays a material design icon as an image.
Image.network
Purpose: A widget that displays an image from the internet.
Image.asset
Purpose: A widget that displays an image from the local assets.
Icon
Purpose: A widget that displays a material design icon.
IconButton
Purpose: A widget that displays a button with an icon.
CircleAvatar
Purpose: A widget that displays a circular avatar.
Material Design Widgets
Card
Purpose: A widget that displays a material design card.
AppBar
Purpose: A widget that displays an app bar with a title and optional actions.
BottomNavigationBar
Purpose: A widget that displays a bottom navigation bar.
FloatingActionButton
Purpose: A widget that displays a floating action button.
Material
Purpose: A widget that sets the material design for its children.
AlertDialog
Purpose: A widget that displays a material design alert dialog.
Cupertino Design Widgets
CupertinoApp
Purpose: A widget that sets up the necessary cupertino design elements for an app.
CupertinoNavigationBar
Purpose: A widget that displays a cupertino-style navigation bar.
CupertinoButton
Purpose: A widget that displays a cupertino-style button.
CupertinoAlertDialog
Purpose: A widget that displays a cupertino-style alert dialog.
CupertinoPicker
Purpose: A widget that displays a cupertino-style picker.
Other Important Widgets
WebView
Purpose: A widget that displays a web page in the app.
VideoPlayer
Purpose: A widget that displays a video player in the app.
PageView
Purpose: A widget that displays a scrollable list of pages.
Stepper
Purpose: A widget that displays a material design stepper.
ShaderMask
Purpose: A widget that applies a shader to its child.
BackdropFilter
Purpose: A widget that applies a filter to its child.
This is just a selection of some commonly used Flutter widgets. The Flutter ecosystem is vast, and there are many more widgets and features to explore. Happy coding with Flutter!