ingredientsToJson static method

List<Map<String, dynamic>>? ingredientsToJson(
  1. List<Ingredient>? ingredients
)

Returns a JSON map from Ingredients

Implementation

static List<Map<String, dynamic>>? ingredientsToJson(
    List<Ingredient>? ingredients) {
  if (ingredients == null || ingredients.isEmpty) {
    return null;
  }

  List<Map<String, dynamic>> result = [];

  for (Ingredient ingredient in ingredients) {
    result.add(ingredient.toJson());
  }

  return result;
}