Ask Your Question
4

How to maintain state across different pages using flutter?

asked 2021-06-28 11:00:00 +0000

lakamha gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-01-16 23:00:00 +0000

pufferfish gravatar image

There are multiple ways to maintain state across different pages in Flutter.

  1. InheritedWidget and InheritedModel:

InheritedWidget and InheritedModel allow you to pass state down the Widget tree to its descendants. It is a great option for smaller applications that require passing down simple data or information.

  1. Provider:

Provider is a Flutter package that provides an easy and efficient way to share state between different screens/pages. It is a popular option for many developers since it allows for dependency injection and can easily scale for larger applications.

  1. Stateful widget:

Stateful widgets are used when you need to manage state within a single widget. In some cases, you might prefer to maintain state within a specific page or screen. You can then pass down state from this widget to a child widget.

  1. BLoC pattern:

BLoC is a design pattern in Dart and Flutter that separates the presentation layer from the business logic layer. It allows for state management across various screens and helps to keep your code organized and structured.

Ultimately, the approach you take to maintain state across different pages in Flutter will depend on the size and complexity of your application, personal preferences, and requirements.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-06-28 11:00:00 +0000

Seen: 20 times

Last updated: Jan 16 '23