editMeal method

Future<bool> editMeal({
  1. required Meal meal,
  2. required User user,
})

Edits an existing meal in either the local database or the API.

  • meal: The Meal object containing the updated meal details.
  • user: The User object representing the current user.

Returns a Future<bool> indicating whether the meal was successfully edited.

Implementation

Future<bool> editMeal({required Meal meal, required User user}) async {
  if (useLocalDb) {
    // Edit meal in the local database
    return await _mealDatabaseRepo.updateMeal(meal: meal, userID: user.ID);
  } else {
    final ApiReturn apiResponse = await _apiConnector.getMealRepo().editMeal(meal: meal, user: user);
    return apiResponse.success;
  }
}