Skip to content

Commit

Permalink
fix: 634 - mapped tag 'energy' to Nutrient energyKj. (#644)
Browse files Browse the repository at this point in the history
Impacted file:
* `Nutrient.dart`: now manages the special duplicate case `'energy'` / `'energy-kj'`
  • Loading branch information
monsieurtanuki authored Dec 17, 2022
1 parent 5bf2959 commit 3957139
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/model/Nutrient.dart
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ enum Nutrient implements OffTagged {
final String offTag;

/// Returns the first [Nutrient] that matches the [offTag].
static Nutrient? fromOffTag(final String? offTag) =>
OffTagged.fromOffTag(offTag, Nutrient.values) as Nutrient?;
///
/// Special case for [offTag] 'energy', which can be found in
/// [OrderedNutrient], and is a duplicate of 'energy-kj'.
static Nutrient? fromOffTag(final String? offTag) => offTag == 'energy'
? Nutrient.energyKJ
: OffTagged.fromOffTag(offTag, Nutrient.values) as Nutrient?;
}

0 comments on commit 3957139

Please sign in to comment.