addMeal method
Adds a new meal to either the local database or the API.
meal: TheMealobject containing the meal details to be added.user: TheUserobject representing the current user.
Returns a Future<bool> indicating whether the meal was successfully added.
Implementation
Future<bool> addMeal({required Meal meal, required User user}) async {
if (useLocalDb) {
// Add meal to the local database
await _mealDatabaseRepo.addMeal(meal: meal, userID: user.ID);
return true;
} else {
// Add meal via the API
final ApiReturn apiResponse = await _apiConnector.getMealRepo().addMeal(meal: meal, user: user);
return apiResponse.success;
}
}