As we are familiar with frameworks like Angular, React, Vue we already know the concept of components. In the world of flutter these components are called Widget.
Widgets are UI components, written in Dart language. Widget is a high-level object that can be used to describe any part of an application. Widgets are used to display something. In flutter everything you’ll code is inside Widgets.
Basically widgets describe what users can see in their applications.
The view of the screen totally depends upon the widgets and the complete screen is called tree of widgets.
Flutter has a lot of widgets to design the application like Row, Container, Column, Text and many many more… also you can customize the widgets based on your requirements.
Widgets can be categorized based on their functionality:
- Animation and motion
- Assets, images, icons
- Interaction model
- Material components
- Painting and effects
There are two state management widgets
- Stateless Widgets
- Stateful Widgets
A stateless widget is the one whose state cannot be change once they are built and doesn’t maintain its state. These types of widgets are generally known as immutable widgets.
Here state refers to the data inside the widgets that will be changed during the lifetime of an application. State of an app defined as anything that exist in memory of the app while app is running
A stateful widget is the one whose state can be changed anytime during the life cycle of an app. These types of widgets are called mutable widgets. Such widgets can change state with variables, inputs, data.
Few Flutter Widgets
- Scaffold: The basic material design structure that provides visual layout.
- Center: To apply a center alignment to widgets.
- Text: To write text on the screen.
- Image: To place images in your application.
- Icon: A widget that draws graphical icon.
Hope you like this!
Keep helping and happy 😄 coding