This tutorial follows an architectural pattern inspired by FilledStacks. There are many different kinds of Providers, most of which are outside the scope of this tutorial. See the Manage State with Provider video series for a fuller explanation of state and Providers. It’s a widget that makes some value – like a state model object – available to the widgets below it.Ī Consumer widget, which is also part of the Provider package, listens for changes in the value and then rebuilds the widgets below itself when changes occur. Thus, the business logic manages the state, not Provider. These variables are part of the business logic, grouped and managed by model objects. The state is the current value of the app’s variables. Is Provider the state management? No, not in this app anyway. Flutter itself is a UI framework and Provider is a widget for that framework. This next part is important to understand: The UI, Flutter, and Provider are all contained in one part of the app. Likewise, where the web API gets its data doesn’t matter to the rest of the app. The local storage uses shared preferences, but that’s an implementation detail that doesn’t affect the rest of the app. Local storage, the web API, and the UI along with Flutter and Provider, are all completely separate from the business logic and from one another. The business logic in the middle handles the calculations related to currency exchange. The Moola X app architecture follows this principle. This is useful for making scalable, maintainable and testable apps. You can replace your mobile UI with a desktop UI and the rest of the app doesn’t care. You can swap one database framework for another and the rest of the app doesn’t even know there was a change. What does this mean? It gives you a plug-in architecture. Everything goes through the business logic from a single location. You shouldn’t scatter direct calls to the database across your app. The UI shouldn’t communicate directly with the web. Why? The core business logic doesn’t change frequently, while all the others often do. The goal is to keep core business logic separate from the UI, database, network and third-party packages. If you haven’t heard about the principles of clean architecture, please read about them before continuing. However, the tutorial will walk you through how to create each part so that you can follow the same pattern when you make your own apps.īut before you add some code, first some theory on the purpose of Provider. The starter project already includes some code so you can finish this project in a single tutorial. Open the starter project by navigating to the starter folder and clicking Get dependencies when Android Studio prompts you to do so. Here’s what it will look like when you’re done: Moola X will let you select and convert between different currencies. This tutorial uses Android Studio, but Visual Studio Code will work fine as well. You’ll learn more from this tutorial by following along step-by-step than you will if you only read through it. If you are new to Flutter, check out Getting Started with Flutter first.ĭownload the project by clicking the Download Materials button at the top or bottom of the page. Note: This tutorial assumes you are comfortable with Dart and know how to build a simple Flutter app by composing widgets into a tree.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |