You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3e9e430
Browse filesBrowse the repository at this point in the historyBrowse files
Fixes tests occasionally failing in CI where `GEMINI_API_KEY` is not present in the system environment by explicitly exposing an `environmentOverride` variable to `BaseSkillCommand` instead of relying completely on `Platform.environment`.
description: Configure Flutter SDK on the user's machine, setup IDEs, and diagnose CLI errors.
3
+
instructions: |
4
+
Architecture is a broad term that can refer to many topics depending on the context. In the context of Flutter, architecture refers to how to structure, organize, and design your Flutter app to scale as project requirements and teams grow. It is an important part of building a maintainable, resilient, and scalable Flutter app. This guide covers app architecture principles and best practices for building Flutter apps.
5
+
6
+
Good app architecture provides several benefits to engineering teams and end users. It makes it easier to modify, update, and fix issues over time (maintainability). A well-thought-out application allows more people to contribute to the same codebase concurrently with minimal code conflicts (scalability).
7
+
8
+
Common architectural principles include separation of concerns, layered architecture, single source of truth, unidirectional data flow, UI as a function of (immutable) state, extensibility, and testability.
9
+
10
+
Flutter applications should be written in layers. Layered architecture is a software design pattern that organizes an application into distinct layers, each with specific roles and responsibilities. Typically, applications are separated into 2 to 3 layers, depending on complexity. The three common layers of app architecture are the UI layer, logic layer, and data layer.
11
+
12
+
* **UI layer** (also known as the 'presentation layer') displays data to the user that is exposed by the business logic layer and handles user interaction. In Flutter, this applies to widgets, which are the basic building blocks of a Flutter user interface. You should write reusable, lean widgets that hold as little logic as possible.
13
+
* **Logic layer** (commonly known as the 'domain layer') implements core business logic and facilitates interaction between the data layer and UI layer. This layer is optional and only needs to be implemented if your application has complex business logic that happens on the client. Many apps are only concerned with presenting data to a user and allowing the user to change that data (colloquially known as CRUD apps).
14
+
* **Data layer** (known as the model in MVVM terminology) is the source of truth for all application data. It handles business data and logic. As the source of truth, it's the only place that application data should be updated. It is responsible for consuming data from various external APIs, exposing that data to the UI, handling events from the UI that require data to be updated, and sending update requests to those external APIs as needed. The data layer typically has two main components: repositories and services.
15
+
* **Repositories** are the source of truth for your model data. They contain logic related to that data, such as updating data in response to user events or polling for data from services. Repositories are responsible for synchronizing data when offline capabilities are supported, managing retry logic, and caching data. They transform raw data into domain models, which represent the data the application needs, formatted for consumption by view model classes.
16
+
* **Services** are stateless Dart classes that interact with APIs, such as HTTP servers and platform plugins. Their only job is to wrap an external API. Any data your application needs that isn't created inside the application code itself should be fetched from within service classes. There is generally one service class per data source.
17
+
18
+
Within each layer, you should further separate your application by feature or functionality. For example, your application's authentication logic should be in a different class than the search logic.
19
+
20
+
The Flutter team's recommended app architecture includes common architectural principles, MVVM and state management, dependency injection, and common design patterns for writing robust Flutter applications.
0 commit comments