Chapter 9. Working with Widgets
In this chapter, we continue our journey with the Flutter framework. We now progress to a high-level overview of the most common widgets.
Widgets are an essential concept in Flutter and provide the basis of most applications. Learning how to integrate the numerous widget types available will significantly enhance your development skills. You will learn:
-
What a Scaffold widget is
-
How to refactor widgets for better build context performance
-
What stateless and stateful widgets are
-
How to build interfaces using Row and Column widgets
Refactoring your code is a skill that I highly recommend to avoid bugs and aid general performance. The chapter takes a brief moment to look at refactoring widgets. A widget represents a customizable user interface element, and Flutter provides the flexibility to build out beautiful interfaces without too much effort.
A strong point of Flutter is its ability to enable you to build feature-rich and beautiful interfaces very quickly. Making steady improvements in your code will also build your confidence and provide the least resistance path to working on more complex applications. Over the course of this chapter, we will continue our journey to explore the variety of widgets available to Flutter.
9.1 Creating a Stateless Widget in Flutter
Problem
You do not need to save state (i.e., save a value) associated with on-screen content.
Solution
Use a stateless widget to render on-screen content.
Here’s an example ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access