Bird
Raised Fist0
Fluttermobile~20 mins

Clean Architecture layers in Flutter - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Clean Architecture Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Identify the correct Clean Architecture layer for UI code
In Flutter Clean Architecture, where should you place your widgets and UI code?
AIn the Presentation layer
BIn the Domain layer
CIn the Data layer
DIn the Infrastructure layer
Attempts:
2 left
💡 Hint
Think about where the user sees and interacts with the app.
🧠 Conceptual
intermediate
2:00remaining
Role of the Domain layer in Clean Architecture
What is the main responsibility of the Domain layer in Clean Architecture for Flutter apps?
AManaging UI state and widgets
BHandling business rules and use cases
CFetching data from APIs or databases
DImplementing platform-specific code
Attempts:
2 left
💡 Hint
This layer contains the core logic that does not depend on UI or data sources.
❓ ui_behavior
advanced
2:00remaining
Effect of mixing Data layer code in Presentation layer
What happens if you put API calls directly inside Flutter widgets in the Presentation layer?
AThe app runs faster because data is fetched directly in UI
BThe app will crash due to missing dependencies
CThe Domain layer automatically handles the API calls
DThe app becomes harder to maintain and test because UI and data logic are mixed
Attempts:
2 left
💡 Hint
Consider separation of concerns and testability.
❓ lifecycle
advanced
2:00remaining
Dependency direction in Clean Architecture
In Clean Architecture, which direction should dependencies flow between layers?
AOnly between Presentation and Data layers, skipping Domain
BFrom Domain layer outward to Data and Presentation layers
CFrom outer layers (Presentation, Data) inward to Domain layer
DBetween layers in both directions freely
Attempts:
2 left
💡 Hint
Think about which layer is the core and should not depend on others.
🔧 Debug
expert
3:00remaining
Identifying layer violation causing test failure
You wrote a unit test for a Domain use case but it fails because it tries to access Flutter widgets. What is the likely cause?
AThe Domain layer code is incorrectly importing Presentation layer widgets
BThe Data layer is missing API implementation
CThe Domain layer is missing dependency injection
DThe Presentation layer is not initialized
Attempts:
2 left
💡 Hint
Domain layer should not depend on UI code.

Practice

(1/5)
1. Which layer in Clean Architecture is responsible for handling the user interface in a Flutter app?
easy
A. Domain layer
B. Presentation layer
C. Data layer
D. Network layer

Solution

  1. Step 1: Understand the role of each layer

    The Presentation layer manages UI elements and user interactions.
  2. Step 2: Match the layer to UI responsibility

    Since UI is about what the user sees and interacts with, it belongs to the Presentation layer.
  3. Final Answer:

    Presentation layer -> Option B
  4. Quick Check:

    UI = Presentation layer [OK]
Hint: UI always belongs to Presentation layer [OK]
Common Mistakes:
  • Confusing Domain layer with UI
  • Thinking Data layer handles UI
  • Assuming Network layer is part of UI
2. Which of the following is the correct way to describe the Domain layer in Clean Architecture?
easy
A. It contains business logic and rules.
B. It handles data storage and retrieval.
C. It manages UI components and widgets.
D. It deals with network requests and APIs.

Solution

  1. Step 1: Identify the Domain layer's responsibility

    The Domain layer contains the core business logic and rules of the app.
  2. Step 2: Eliminate incorrect options

    Data storage is Data layer, UI is Presentation, network is part of Data or external services.
  3. Final Answer:

    It contains business logic and rules. -> Option A
  4. Quick Check:

    Domain = Business logic [OK]
Hint: Domain layer = business rules and logic [OK]
Common Mistakes:
  • Mixing Domain with Data layer
  • Thinking Domain manages UI
  • Confusing network tasks with Domain
3. Given the following Flutter app structure, which layer should contain the repository interface?
lib/
  presentation/
  domain/
    repositories/
  data/
    repositories_impl/
medium
A. Presentation layer
B. Data layer
C. Domain layer
D. UI layer

Solution

  1. Step 1: Understand repository interface placement

    Repository interfaces define contracts for data access and belong in the Domain layer.
  2. Step 2: Check the folder structure

    Domain layer has 'repositories' folder for interfaces; Data layer has 'repositories_impl' for implementations.
  3. Final Answer:

    Domain layer -> Option C
  4. Quick Check:

    Repository interface = Domain layer [OK]
Hint: Interfaces go in Domain, implementations in Data [OK]
Common Mistakes:
  • Putting interfaces in Data layer
  • Confusing UI layer with Presentation
  • Ignoring folder naming conventions
4. In a Flutter app using Clean Architecture, a developer places API call code directly inside a widget class. What is the main problem with this approach?
medium
A. It violates the separation of concerns by mixing UI and data logic.
B. It improves app performance by reducing layers.
C. It follows Clean Architecture best practices.
D. It makes the Domain layer responsible for UI.

Solution

  1. Step 1: Identify the problem with API calls in UI

    API calls belong in the Data layer, not in UI widgets.
  2. Step 2: Understand separation of concerns

    Mixing UI and data logic breaks Clean Architecture principles, making code harder to maintain.
  3. Final Answer:

    It violates the separation of concerns by mixing UI and data logic. -> Option A
  4. Quick Check:

    UI should not contain data logic [OK]
Hint: Keep API calls out of UI widgets [OK]
Common Mistakes:
  • Thinking mixing layers improves performance
  • Assuming Domain layer handles UI
  • Believing this is best practice
5. You want to add a new feature to your Flutter app that fetches user profiles from a remote server. According to Clean Architecture, where should you place the code that converts JSON data into Dart objects?
hard
A. In the Presentation layer inside widgets
B. In the Domain layer as part of business logic
C. Directly inside the main.dart file
D. In the Data layer within model or mapper classes

Solution

  1. Step 1: Identify JSON conversion responsibility

    Converting JSON to Dart objects is a data transformation task, part of data handling.
  2. Step 2: Match task to Clean Architecture layer

    Data layer handles data sources and transformations, so JSON parsing belongs here.
  3. Step 3: Exclude other layers

    Presentation is UI only, Domain is business rules, main.dart is app entry point, not for data parsing.
  4. Final Answer:

    In the Data layer within model or mapper classes -> Option D
  5. Quick Check:

    JSON parsing = Data layer [OK]
Hint: Put JSON parsing in Data layer models/mappers [OK]
Common Mistakes:
  • Parsing JSON in UI widgets
  • Putting parsing in Domain layer logic
  • Adding parsing code in main.dart
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard