Article image Widgets in Flutter: Basic Widgets in Flutter

6.3. Widgets in Flutter: Basic Widgets in Flutter

Page 75 | Listen in audio

Flutter is an application development platform that was created by Google. Flutter is known for its ease of use, efficiency and flexibility. One of the main components of Flutter is Widgets. Widgets are the basic building blocks of a user interface (UI) in Flutter. They are immutable and must be rebuilt whenever the data they represent changes.

To start exploring basic widgets in Flutter, we first need to understand what widgets are. A widget is a description of a part of the user interface. They are used to build the structure and layout of an application. Widgets are nested inside each other to form a widget tree. Each widget is a Dart class that can be reused and combined with other widgets to create complex layouts.

There are two main types of widgets in Flutter: stateless widgets and stateful widgets. Stateless widgets are those that describe a part of the user interface that can be uniquely determined by settings at a specific point in time. They cannot change over time. On the other hand, stateful widgets are those that can change over time. They have an internal state that can change over time.

Some of the basic widgets in Flutter include:

1. Container

The Container is a convenient widget that combines common painting, positioning, and scaling widgets. It can contain a single child and has properties to manipulate the child's layout. A Container tries to be as big as possible, but if it is constrained by external constraints, it will try to fit those constraints.

2. Row and Column

Row and Column are flexible widgets that allow their children to be linearly aligned along the main axis. They can have multiple children and allow you to specify how their children should be positioned along the major and cross axis.

3. Stack

A Stack allows you to layer multiple widgets on top of each other. It can have multiple children, and you can control how the children are positioned relative to the corners of your box. This is useful when you want to layer multiple widgets on top of each other.

4. Text

The Text widget allows you to display a single-styled snippet of text. Text may span multiple lines or be truncated depending on layout constraints.

5. Icon

The Icon widget is a graphical representation of a material design icon. It takes the name of the icon (from material design icons) as a parameter and draws the corresponding icon on the screen.

These are just a few examples of basic widgets you can use when building apps with Flutter. There are many other widgets available, each with its own unique properties and behavior. By combining these widgets in different ways, you can create a wide variety of layouts and user interfaces.

When building an app with Flutter, it's important to remember that everything is a widget. Even the most complex UI elements can be broken down into smaller, more manageable widgets. This makes Flutter a powerful tool for building rich, interactive user interfaces.

In conclusion, widgets are a fundamental part of Flutter. They are the foundation upon which everything else is built. By understanding how to use widgets, you can start building amazing apps with Flutter.

Now answer the exercise about the content:

What is the main feature of stateless widgets in Flutter?

You are right! Congratulations, now go to the next page

You missed! Try again.

Article image Widgets in Flutter: Layouts in Flutter

Next page of the Free Ebook:

76Widgets in Flutter: Layouts in Flutter

3 minutes

Earn your Certificate for this Course for Free! by downloading the Cursa app and reading the ebook there. Available on Google Play or App Store!

Get it on Google Play Get it on App Store

+ 6.5 million
students

Free and Valid
Certificate with QR Code

48 thousand free
exercises

4.8/5 rating in
app stores

Free courses in
video, audio and text