nutrition_ai 3.2.12
nutrition_ai: ^3.2.12 copied to clipboard
Passio Nutrition AI SDK for Flutter. Supports Android and iOS.
3.2.12 #
- Bumped the version up to match other platform versions.
3.2.11 #
- Added a new function
updateProductLocalizationto customize results for API calls.
/// Sets the `Passio-Product-Localization` header to control language and region
/// for product search results. This affects localized product names, descriptions,
/// and enables region-specific semantic search tools.
///
/// **Parameters**
/// - [localizationCode]: Accepts BCP47 language tags or ISO 639-1 codes
/// (e.g., `"en"` for English, `"fr"` for French, `"de"` for German).
///
/// **Returns**
/// A `bool` indicating whether the localization setting was applied successfully.
///
/// ### Format
/// Examples of valid codes:
/// - `en-US` — English (United States)
/// - `en-GB` — English (United Kingdom)
/// - `ja-JP` — Japanese (Japan)
/// - `es-MX` — Spanish (Mexico)
/// - `fr-FR` — French (France)
/// - `de-DE` — German (Germany)
/// Or just language codes: `en`, `ja`, `es`, `fr`, `de`.
///
/// ### What It Does
/// - **Regional Semantic Search**: Uses region-specific semantic search tools if available.
/// - **Translation**: Translates responses to the target language if different from source.
/// - **Regional Preferences**: Optimizes results for the specified region.
///
/// ### Example
/// ```dart
/// final success = await updateProductLocalization("en-US");
Future<bool> updateProductLocalization(String? localizationCode) async {
return NutritionAIPlatform.instance.updateProductLocalization(localizationCode);
}
- Added a new function
updateSearchConfigurationto customize search behavior.
/// Sets the `Passio-Search-Config` header to customize search behavior, data sources,
/// and filtering options. All search and food endpoints support this header.
///
/// **Parameters**
/// - [config]: A JSON string containing the search configuration.
///
/// ### Filter Configuration
/// **Region Filters**
/// - Controls geographic filtering and boosting.
/// - Accepts a map with region codes as keys and priorities (1–10) as values.
/// - Priority 1 = highest preference, Priority 10 = lowest.
/// - Valid codes: ISO2 (`us`, `gb`, `jp`), BCP47 (`en-US`, `en-GB`), or language codes (`en`, `ja`, `es`).
/// - Example: `{"regionFilters": {"us": 1, "gb": 3, "ja": 1}}`
/// - `strictRegionMode = true`: Only shows items from specified regions (branded items only).
/// - `strictRegionMode = false`: Boosts matching regions in results.
///
/// **Source Filters**
/// - Strict filtering by data source.
/// - Accepts an array of source names: `fdc`, `firebase`, `legacy`, `openfood`, `passio`, `passio-foodai`.
/// - Example: `{"sourceFilters": ["fdc", "passio"]}`
///
/// **Type Filters**
/// - Filter by item category.
/// - Accepts an array: `generic`, `branded`, `recipe`.
/// - Example: `{"typeFilters": ["branded", "generic"]}`
///
/// **Strict Region Mode**
/// - `true`: Removes items without country data (strict regional search).
/// - `false`: Keeps items without country data (default).
/// - `null` or omitted: Uses global default.
///
/// ### Data Source Configuration
/// **Data Source Configs**
/// - `passio`: Main Passio DB (included: 100 results, max: 1000).
/// - `edamam_ingredients`: Edamam ingredient DB (included: 10, max: 50).
/// - `edamam_recipes`: Edamam recipe DB (included: 0, max: 25).
///
/// ### Concern Flags
/// **Ignore With Concern Flags**
/// - Filters out items with specific data quality concerns.
/// - Example: `{"ignoreWithConcernFlags": [1002, 1100, 1211]}`
/// - Common codes:
/// - `1002`: Missing essential nutrients.
/// - `1100`: Invalid serving size.
/// - `1205`: Excessive sodium.
/// - `1211`: Sum of nutrients exceeded 100g.
/// - `1300`: Missing ingredients list.
///
/// ### Complete Example
/// ```json
/// {
/// "dataSourceConfigs": [
/// {"name": "passio", "requestResultCount": 100},
/// {"name": "edamam_ingredients", "requestResultCount": 10}
/// ],
/// "regionFilters": {"us": 1, "gb": 3},
/// "typeFilters": ["branded"],
/// "sourceFilters": ["fdc", "passio"],
/// "strictRegionMode": false,
/// "ignoreWithConcernFlags": [1002, 1100]
/// }
/// ```
///
/// **Notes**
/// - Filters apply after search results are retrieved.
/// - Caching is disabled when filters are active.
/// - Generic items (USDA reference foods) are exempt from region filtering by default.
/// - Filtering reduces token costs by returning fewer results.
Future<void> updateSearchConfiguration(String? config) async {
return NutritionAIPlatform.instance.updateSearchConfiguration(config);
}
3.2.10 #
- Added support for Google Play's 16KB compatibility requirement.
3.2.9 #
Added APIs #
- Added a function to fetch all nutrients of a food item as a raw json string called
fetchNutrientsJSON. - Added field
concernsto PassioFoodDataInfo, representing a list of concern flag ids.
3.2.6 #
Added APIs #
- Added a new function
generateMealPlanto generate meal plan from request string.
Future<PassioResult<PassioGeneratedMealPlan>> generateMealPlan(String request)
- Added a new function
generateMealPlanPreviewto generate meal plan preview from request string.
Future<PassioResult<PassioGeneratedMealPlan>> generateMealPlanPreview(String request)
- Added a new function
recognizeSpeechRemoteWithGroupingto recognize speech input and group recognized food items by meal.
Future<PassioResult<PassioRecognitionResult>> recognizeSpeechRemoteWithGrouping(String text)
- Added a new function
recognizeImageRemoteWithGroupingto recognize food items from an image and group them by meal.
Future<PassioResult<PassioRecognitionResult>> recognizeImageRemoteWithGrouping(Uint8List bytes, {PassioImageResolution resolution = PassioImageResolution.res_512, String? message})
Removed APIs #
- Removed
transformCGRectFormfunction - Removed
startNutritionFactsDetectionfunction - Removed
stopNutritionFactsDetectionfunction - Removed
PassioNutritionFactsclass
3.2.5+1 #
- Fixed iOS build issues for smoother project setup.
3.2.5 #
Added APIs #
- Added a new function
fetchUltraProcessingFoodRatingthat provides the ultra-processing food rating for a given food item:
Future<PassioResult<PassioUPFRating>> fetchUltraProcessingFoodRating(PassioFoodItem foodItem) async {
return NutritionAIPlatform.instance.fetchUltraProcessingFoodRating(foodItem);
}
class PassioUPFRating {
final String chainOfThought;
final List<String> highlightedIngredients;
final int? rating;
}
- Added field concerns to the
PassioFoodMetadataobject
final List<int>? concerns;
Deprecated APIs #
- Deprecated the following local recognition functions, which will be removed in a future release. Use
recognizeImageRemoteinstead:startFoodDetectionstopFoodDetectionstartNutritionFactsDetectionstopNutritionFactsDetection
Removed APIs #
- Removed volume detection related functionality from the SDK.
3.2.4 #
Added APIs #
- Added two new parameters to the
PassioConfigurationclass:proxyUrlandproxyHeaders. If supplied, the SDK will use theproxyUrlvalue as a base url when executing networking calls, and will append the providedproxyHeadersto the request itself. WhenproxyUrlis provided, the SDK operates inremoteOnlystate.
3.2.3 #
Added APIs #
- Added a new search function that provides contextually connected items to the search term:
Future<PassioSearchResponse> searchForFoodSemantic(String term) async {
return NutritionAIPlatform.instance.searchForFoodSemantic(term);
}
- Added a new api for a recipe builder feature, that gives a list of predicted next ingredients based on the current list of ingredients in the recipe:
Future<List<PassioFoodDataInfo>> predictNextIngredients(List<String> currentIngredients) async {
return NutritionAIPlatform.instance.predictNextIngredients(currentIngredients);
}
Refactored APIs #
- Refactored
PassioNutritionFacts: renamedservingSizeQuantitytoservingQuantityandservingSizeUnitNametoservingUnit; removedservingSize; addedweightQuantityandweightUnit. - Refactored
fetchTagsForandfetchInflammatoryEffectDatato acceptrefCodeas a parameter instead ofpassioID.
Removed APIs #
- Removed function
detectFoodIn. Instead,recognizeImageRemoteshould be used
3.2.1+1 #
- Fixed Android build issues for smoother project setup.
3.2.1 #
⚠️ Breaking Changes #
- Configuration for Android is no longer required. Please remove any code related to finding the AAR file from your top build.gradle file (Project: android).
Refactored APIs #
- The
fetchFoodItemForDataInfomethod now includes optionalservingQuantityandservingUnitparameters to provide details based on the specified serving size:
Future<PassioFoodItem?> fetchFoodItemForDataInfo(PassioFoodDataInfo passioFoodDataInfo, {double? servingQuantity, String? servingUnit})
Added APIs #
- Added the
reportFoodItemfunction to report incorrect food items:
Future<PassioResult<bool>> reportFoodItem({String refCode = '', String productCode = '', List<String>? notes})
- Added the
submitUserCreatedFoodfunction to submit user-created food items:
Future<PassioResult<bool>> submitUserCreatedFood(PassioFoodItem item)
3.2.0+1 #
3.2.0 #
Added APIs #
- Added function
recognizeNutritionFactsRemotethat can parse the nutrition facts table from an image and return aPassioFoodItemwith the scanned nutrients
Future<PassioFoodItem?> recognizeNutritionFactsRemote(Uint8List bytes, {PassioImageResolution resolution = PassioImageResolution.res_1080})
- Added support for localized content. Using
updateLanguagewith a two digit ISO 639-1 language code will transform the food names and serving sizes in the SDK responses.
Future<bool> updateLanguage(String languageCode)
- Added
remoteOnlyflag to thePassioConfigurationclass. With this flag enabled, the SDK won't download the files needed for local recognition. In this case only remote recognition is possible.
class PassioConfiguration{
...
final bool remoteOnly;
}
Refactored APIs #
recognizeImageRemotecan now scan barcodes and nutrition facts. ThePassioAdvisorFoodInfoclass has been augmented to handle these responses
class PassioAdvisorFoodInfo {
final PassioFoodDataInfo? foodDataInfo;
final PassioFoodItem? packagedFoodItem;
final String portionSize;
final PassioFoodResultType resultType;
final String recognisedName;
final double weightGrams;
}
enum PassioFoodResultType {
foodItem,
barcode,
nutritionFacts,
}
- Property
tagswas added toPassioFoodDataInfo
class PassioFoodDataInfo {
...
final List<String>? tags;
}
- Vitamin A RAE was added to the
PassioNutrientsclass.
class PassioNutrients {
...
final UnitMass? _vitaminARAE;
}
3.1.4+2 #
- Improved scanning performance on Android
3.1.4 #
Added APIs #
- With the new key comes the new pricing model using tokens. Although all token usage can be seen in the portal, the SDK itself offers a listener to count the tokens being used by the SDK.
void setAccountListener(PassioAccountListener? listener)
abstract interface class PassioAccountListener {
void onTokenBudgetUpdate(PassioTokenBudget tokenBudget);
}
class PassioTokenBudget {
final String apiName;
final int budgetCap;
final int periodUsage;
final int tokensUsed;
}
- Control Flashlight: Manage the flashlight with:
/// [enabled] A required parameter to turn the flashlight on or off.
/// [level] An optional parameter specifying the intensity level of the flashlight, with a default value of 1. Note that the level parameter is only applicable on iOS for now.
Future<void> enableFlashlight({required bool enabled, double level = 1})
- Get Camera Zoom Levels: Retrieve the minimum and maximum zoom levels with:
Future<PassioCameraZoomLevel> getMinMaxCameraZoomLevel()
class PassioCameraZoomLevel {
final double? minZoomLevel;
final double? maxZoomLevel;
}
- Set Camera Zoom Level: Adjust the camera zoom level:
/// [zoomLevel] Sets the desired zoom level. Ensure it’s within the range obtained from ```getMinMaxCameraZoomLevel()```.
Future<void> setCameraZoomLevel({required double zoomLevel})
Refactored APIs #
- Updated the fetchFoodItemForDataInfo method to include an optional weightGrams parameter:
/// [weightGrams] An optional parameter that provides information specific to the specified weight in grams.
Future<PassioFoodItem?> fetchFoodItemForDataInfo(PassioFoodDataInfo passioFoodDataInfo,{double? weightGrams})
- The
NutritionAdvisorno longer needs a separate key for configuration. The PassioSDK needs to be configured in order to call the NutritionAdvisor APIs. Also, any previous NutritionAdvisor keys won't work with this version, a new key needs to be obtained at https://www.passio.ai/
3.1.1 #
Added APIs #
- Added
PassioImageResolution resolutionas a parameter of therecognizeImageRemotefunction. This enables the caller to set the target resolution of the image uploaded to the server. Smaller resolutions will result in faster response times, while higher resolutions should provide more accurate results.
enum PassioImageResolution {
res_512,
res_1080,
full,
}
- Added a function to retrieve possible hidden ingredients for a given food name.
Future<PassioResult<List<PassioAdvisorFoodInfo>>> fetchHiddenIngredients(String foodName)
- Added a function to retrieve possible visual alternatives for a given food name.
Future<PassioResult<List<PassioAdvisorFoodInfo>>> fetchVisualAlternatives(String foodName)
- Added a function to retrieve possible ingredients if a more complex food for a given food name.
Future<PassioResult<List<PassioAdvisorFoodInfo>>> fetchPossibleIngredients(String foodName)
3.1.0 #
New Features #
Nutrition AI Advisor
- To access the API of the Advisor use
NutritionAdvisor.instance - The method
Future<PassioResult<PassioAdvisorResponse>> fetchIngredients(PassioAdvisorResponse response)works only with the response fromsendMessage(). It returns data if thePassioAdvisorResponsecontainstools.
Future<PassioResult> configure(String key)
Future<PassioResult> initConversation()
Future<PassioResult<PassioAdvisorResponse>> sendMessage(String message)
Future<PassioResult<PassioAdvisorResponse>> sendImage(Uint8List bytes)
Future<PassioResult<PassioAdvisorResponse>> fetchIngredients(PassioAdvisorResponse response)
Nutrition Facts Detection
void startNutritionFactsDetection(NutritionFactsRecognitionListener listener)
Future<void> stopNutritionFactsDetection()
abstract interface class NutritionFactsRecognitionListener {
void onNutritionFactsRecognized(PassioNutritionFacts? nutritionFacts, String? text);
}
Refactored APIs #
- The
FoodDetectionConfigurationobject no longer has the detectNutritionFacts parameter.
Added APIs #
- Added speech recognition API that retrieves a list of recognized foods from the input text query.
Future<List<PassioSpeechRecognitionModel>> recognizeSpeechRemote(String text)
- Added LLM image detection, that works remotely through Passio's backend.
Future<List<PassioAdvisorFoodInfo>> recognizeImageRemote(Uint8List bytes)
- Added a function to retrieve a PassioFoodItem for a v2 PassioID
Future<PassioFoodItem?> fetchFoodItemLegacy(PassioID passioID)
3.0.3 #
Added APIs #
- Added two functions to fetch a list of meal plans and fetch a meal plan for a certain day.
Future<List<PassioMealPlan>> fetchMealPlans()
Future<List<PassioMealPlanItem>> fetchMealPlanForDay(String mealPlanLabel, int day)
- Added
refCodeas an attribute to thePassioFoodItemandPassioIngredientclasses. - Added method to fetch a food item using just the
refCodeattribute
Future<PassioFoodItem?> fetchFoodItemForRefCode(String refCode)
Refactored APIs #
- Refactored PassioSearchNutritionPreview
class PassioSearchNutritionPreview {
final int calories;
final double carbs;
final double fat;
final double protein;
final double servingQuantity;
final String servingUnit;
final double weightQuantity;
final String weightUnit;
}
- Renamed
PassioSearchResulttoPassioFoodDataInfo. - Renamed
fetchFoodItemForSearchResulttofetchFoodItemForDataInfo. - Renamed
MealTimetoPassioMealTime.
Deprecated APIs #
- Removed
fetchFoodItemForSuggestion. NowfetchFoodItemForDataInfois used.
3.0.2 #
Added APIs #
- Added API to fetch suggestion for a certain meal time. To fetch the full nutritional data for a suggestion item use
fetchFoodItemForSuggestion.
enum MealTime {
breakfast,
lunch,
dinner,
snack,
}
Future<List<PassioSearchResult>> fetchSuggestions(MealTime mealTime)
Future<PassioFoodItem?> fetchFoodItemForSuggestion(PassioSearchResult suggestion)
Added Micronutrients: #
- Zinc
- Selenium
- Folic acid
- Chromium
- Vitamin-K Phylloquinone
- Vitamin-K Menaquinone4
- Vitamin-K Dihydrophylloquinone
Refactored APIs #
- Renamed
fetchSearchResulttofetchFoodItemForSearchResult.
3.0.1 #
- Version 3 of the Passio SDK introduces major changes to the nutritional data class and the search functionality. The SDK no longer supports offline work, there is no more local database.
Deprecated APIs #
lookupPassioAttributesForhas been removed because it was querying the local database.- PassioIDAttributes, PassioFoodItemData and PassioFoodRecipe have been removed. The new data model that will handle nutritional data is called PassioFoodItem
Refactored APIs #
searchForFoodnow returns PassioSearchResponse. In PassioSearchResponse you will get list of PassioSearchResult and a list of search options. The PassioSearchResult represent a specific food item associated with the search term.fetchPassioIDAttributesForBarcodeandfetchPassioIDAttributesForPackagedFoodhave been replaced withfetchFoodItemForProductCodethan now returns a PassioFoodItem resultDetectedCandidatenow has an attribute called foodNameFoodRecognitionListenermethodonRecognitionResultscan now return nullable FoodCandidatesfetchNutrientsForhas been renamed tofetchInflammatoryEffectData, and PassioNutrient has been renamed to InflammatoryEffectData
Added APIs #
fetchSearchResultreturns a PassioFoodItem object for a given PassioSearchResultfetchFoodItemForPassioIDreturns a PassioFoodItem object for a given passioID corresponding to a result from the visual detection- Added class PassioSearchResult that represents a result from the searchForFood function
- Added class PassioFoodItem that represent a food item from the Passio Nutritional database. It has a list of PassioIngredients, with their respective PassioFoodAmounts and PassioNutrients
2.3.15 #
- Added
fetchNutrientsFormethod to retrieve a map of nutrients for a 100 grams of a specific food item.
0.0.10 #
- No API changes
0.0.9 #
- Add
PlatformImageparameter to therecognitionResultsof theFoodRecognitionListener. It represents the image that was analyzed by the camera recognition system.
0.0.8 #
- Fixed iOS camera not stopping issue
0.0.7 #
- Fixed Android camera not stopping issue
0.0.6 #
- Removed app bar from
PassioPreview - Fixed issue with food items that don't have an origin
- Fixed Android issue with caching
PassioFoodItemData
0.0.5 #
- Clean up of the example app code
- Added distribution github repository with the source code and issue tracker
0.0.4 #
- Fix issue with PassioSDKError
0.0.3 #
- Add
detectFoodInto run detection from a single image. - Add
fetchTagsForto fetch the list of tags for a food item. - Add
iconURLForto get the url for downloading an icon for a food item. - Add
transformCGRectFormto calculate the bouding box of scanned food item. - Add volume detection using
VolumeDetectionMode - Add
android:required="false"to camera manifest features in Android. - Refactor
lookupIconsForto return a list ofPassioFoodIconsobjects. - Refactor
PassioPreviewwidget to remove all unnecessary widgets.
0.0.2 #
- Add missing .aar dependency
0.0.1 #
- Alpha release of the Nutrition AI SDK for Flutter.
- Visual, barcode and packaged food detection using the camera of the device.
- Fetching nutritional data of the scanned food.
- Searching by food name.
- Fetching the icon for the food item.