Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Managing State in Flutter Pragmatically

You're reading from   Managing State in Flutter Pragmatically Discover how to adopt the best state management approach for scaling your Flutter app

Arrow left icon
Product type Paperback
Published in Nov 2021
Publisher Packt
ISBN-13 9781801070775
Length 246 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Waleed Arshad Waleed Arshad
Author Profile Icon Waleed Arshad
Waleed Arshad
RAHUL AGARWAL RAHUL AGARWAL
Author Profile Icon RAHUL AGARWAL
RAHUL AGARWAL
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Section 1:The Basics of State Management
2. Chapter 1: States and State Management Overview FREE CHAPTER 3. Chapter 2: The Core Building Blocks of State Management 4. Section 2:Types, Techniques, and Approaches
5. Chapter 3: Diving into Advanced State Management Approaches 6. Chapter 4: Adopting State Management Approaches from React 7. Chapter 5: Executing Distinctive Approaches Like GetX, GetIt, and Binder 8. Section 3:Code-Level Implementation
9. Chapter 6: Creating a Shopping Cart Application Using Basic Approaches 10. Chapter 7: Manipulating a Shopping Cart Application through BLoC, Provider, and React-Based Approaches 11. Chapter 8: Using GetX, GetIt, and Binder to Update the Cart Application 12. Chapter 9: Comparative State Management Analysis: When to Use What? 13. Other Books You May Enjoy

What is a state?

Before diving into creating applications and managing states in Flutter, it is necessary to understand what a state actually is and how it affects our application.

Put simply, the state of an application is a condition or a situation – an instance or a snapshot that shows the condition of your application at a certain point in time.

For example, your application shows two variables, x and y, with values 2 and 3 respectively. Let's call this state State A. Now, if there is a user interaction and the values of your variables x and y change to something else, let's say 4 and 5, that would be a different state of your application, State B.

Figure 1.1 – Two different states of an application

Figure 1.1 – Two different states of an application

States A and B are two different conditions of your application. Each one of them denotes a certain set of values of the variables that can be used to identify which state the application is currently in.

Another example of a state would be a counter application that shows an increasing counter every time the user presses a plus button.

Figure 1.2 – Two different states in a counter example app

Figure 1.2 – Two different states in a counter example app

The counter keeps on increasing and the state keeps changing as the user presses the plus button.

To summarize, the state shows your application's current set of values and can be changed based on user interaction.

Now we know what a state is, how it is detected and used within an application, and how it affects your application's UI. To better understand states for a large-scale application, let's see why a state is important in an application.

You have been reading a chapter from
Managing State in Flutter Pragmatically
Published in: Nov 2021
Publisher: Packt
ISBN-13: 9781801070775
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £16.99/month. Cancel anytime