forked from openfoodfacts/openfoodfacts-dart
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 972 - new "product_type" field for Product (openfoodfacts#973)
New file: * `product_type.dart`: Type used at the product level (e.g. "this is a pet food product"). Impacted files: * `openfoodfacts.dart`: exported new file `product_type.dart` * `product.dart`: added a new `ProductType?` field * `product.g.dart`: (generated)
- Loading branch information
1 parent
ddeb7eb
commit 3613a0e
Showing
4 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
import 'off_tagged.dart'; | ||
import '../prices/flavor.dart'; | ||
import '../utils/server_type.dart'; | ||
|
||
/// Type used at the [Product] level (e.g. "this is a pet food product"). | ||
/// | ||
/// Somehow redundant with [ServerType] and [Flavor]. | ||
enum ProductType implements OffTagged { | ||
@JsonValue('food') | ||
food(offTag: 'food'), | ||
|
||
@JsonValue('beauty') | ||
beauty(offTag: 'beauty'), | ||
|
||
@JsonValue('petfood') | ||
petFood(offTag: 'petfood'), | ||
|
||
@JsonValue('product') | ||
product(offTag: 'product'); | ||
|
||
const ProductType({ | ||
required this.offTag, | ||
}); | ||
|
||
@override | ||
final String offTag; | ||
|
||
/// Returns the first [ProductType] that matches the [offTag]. | ||
static ProductType? fromOffTag(final String? offTag) => | ||
OffTagged.fromOffTag(offTag, ProductType.values) as ProductType?; | ||
} |