Skip to content

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.

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.

To connect a real backend:

  1. Create an API Service: Use a package like dio or http.
  2. 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();
}
  1. Update Controllers: Ensure your controllers call these methods asynchronously (await).

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.dart before running the app.