Challenge - 5 Problems
Repository Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:30remaining
What is the main purpose of the Repository pattern in Flutter?
Choose the best explanation for why developers use the Repository pattern in Flutter apps.
Attempts:
2 left
💡 Hint
Think about how to keep your UI code clean and easy to change.
✗ Incorrect
The Repository pattern acts as a middleman between data sources and UI, helping keep code organized and testable.
❓ ui_behavior
intermediate1:30remaining
How does the Repository pattern affect UI updates in Flutter?
If you use a Repository to fetch data, what happens when the data changes?
Attempts:
2 left
💡 Hint
Think about how Flutter knows when to redraw widgets.
✗ Incorrect
Repositories usually notify listeners or use streams so UI can rebuild with fresh data.
❓ lifecycle
advanced2:00remaining
When should you dispose resources in a Repository in Flutter?
Consider a Repository that uses streams to fetch data. When is the best time to close these streams?
Attempts:
2 left
💡 Hint
Think about cleaning up to avoid memory leaks.
✗ Incorrect
Closing streams when the Repository is disposed prevents resource leaks and unexpected behavior.
advanced
2:00remaining
How does the Repository pattern help with navigation decisions in Flutter apps?
If your app needs to decide which screen to show based on user data from a Repository, how should this be handled?
Attempts:
2 left
💡 Hint
Think about separation of concerns between data and UI.
✗ Incorrect
UI listens to Repository data changes and decides navigation, keeping Repository focused on data only.
🔧 Debug
expert2:30remaining
What error will this Flutter Repository code cause?
Consider this Dart code snippet for a Repository:
class UserRepository {
StreamController _controller = StreamController();
Stream get userStream => _controller.stream;
void fetchUser() {
_controller.add('User data');
}
void dispose() {
// Missing _controller.close()
}
}
What problem will happen if dispose() is called without closing _controller?
Attempts:
2 left
💡 Hint
Think about resource cleanup for streams.
✗ Incorrect
Not closing StreamControllers causes memory leaks and can cause errors when listeners remain active.