Data Handling
DashLearn uses a clean repository pattern to manage data fetching. By default, it is configured to use Mock Data suitable for a UI Kit / Showcase environment.
Mock Data Structure
Section titled “Mock Data Structure”All mock data is located in lib/app/data/demo_data/. These files contain static lists of objects used to populate the application.
Common data files:
user_data.dart: Mock profile information.course_data.dart: List of available courses, lessons, and categories.chat_data.dart: Mock conversation history.
Switching to Real API
Section titled “Switching to Real API”To connect a real backend:
- Create an API Service: Use a package like
dioorhttp. - Update Repositories: Modify the files in
lib/app/data/repository/to fetch from your API instead of returning static lists.
// Example: Converting a repository method// BEFORE (Mock)List<Course> getCourses() { return DemoData.courses; // Returns static list}
// AFTER (Real API)Future<List<Course>> getCourses() async { final response = await apiService.get('/courses'); return (response.data as List).map((e) => Course.fromJson(e)).toList();}- Update Controllers: Ensure your controllers call these methods asynchronously (
await).
Wishlist Feature
Section titled “Wishlist Feature”The Wishlist uses local storage (via GetStorage or similar) to persist data on the device.
- Logic is typically handled in
lib/app/modules/wishlist/controllers/wishlist_controller.dart. - Ensure you initialize the storage box in
main.dartbefore running the app.