mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Adds ai_recipe_generation sample (#2242)
Adding the demo app from my I/O talk. Because AI. ## Pre-launch Checklist - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I read the [Contributors Guide]. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] All existing and new tests are passing. --------- Co-authored-by: Brett Morgan <brett.morgan@gmail.com>
This commit is contained in:
66
ai_recipe_generation/lib/features/prompt/prompt_model.dart
Normal file
66
ai_recipe_generation/lib/features/prompt/prompt_model.dart
Normal file
@@ -0,0 +1,66 @@
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
import '../../util/filter_chip_enums.dart';
|
||||
|
||||
class PromptData {
|
||||
PromptData({
|
||||
required this.images,
|
||||
required this.textInput,
|
||||
Set<BasicIngredientsFilter>? basicIngredients,
|
||||
Set<CuisineFilter>? cuisines,
|
||||
Set<DietaryRestrictionsFilter>? dietaryRestrictions,
|
||||
List<String>? additionalTextInputs,
|
||||
}) : additionalTextInputs = additionalTextInputs ?? [],
|
||||
selectedBasicIngredients = basicIngredients ?? {},
|
||||
selectedCuisines = cuisines ?? {},
|
||||
selectedDietaryRestrictions = dietaryRestrictions ?? {};
|
||||
|
||||
PromptData.empty()
|
||||
: images = [],
|
||||
additionalTextInputs = [],
|
||||
selectedBasicIngredients = {},
|
||||
selectedCuisines = {},
|
||||
selectedDietaryRestrictions = {},
|
||||
textInput = '';
|
||||
|
||||
String get cuisines {
|
||||
return selectedCuisines.map((catFilter) => catFilter.name).join(",");
|
||||
}
|
||||
|
||||
String get ingredients {
|
||||
return selectedBasicIngredients
|
||||
.map((ingredient) => ingredient.name)
|
||||
.join(", ");
|
||||
}
|
||||
|
||||
String get dietaryRestrictions {
|
||||
return selectedDietaryRestrictions
|
||||
.map((restriction) => restriction.name)
|
||||
.join(", ");
|
||||
}
|
||||
|
||||
List<XFile> images;
|
||||
String textInput;
|
||||
List<String> additionalTextInputs;
|
||||
Set<BasicIngredientsFilter> selectedBasicIngredients;
|
||||
Set<CuisineFilter> selectedCuisines;
|
||||
Set<DietaryRestrictionsFilter> selectedDietaryRestrictions;
|
||||
|
||||
PromptData copyWith({
|
||||
List<XFile>? images,
|
||||
String? textInput,
|
||||
List<String>? additionalTextInputs,
|
||||
Set<BasicIngredientsFilter>? basicIngredients,
|
||||
Set<CuisineFilter>? cuisineSelections,
|
||||
Set<DietaryRestrictionsFilter>? dietaryRestrictions,
|
||||
}) {
|
||||
return PromptData(
|
||||
images: images ?? this.images,
|
||||
textInput: textInput ?? this.textInput,
|
||||
additionalTextInputs: additionalTextInputs ?? this.additionalTextInputs,
|
||||
basicIngredients: basicIngredients ?? selectedBasicIngredients,
|
||||
cuisines: cuisineSelections ?? selectedCuisines,
|
||||
dietaryRestrictions: dietaryRestrictions ?? selectedDietaryRestrictions,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user