Components · App
Photo Food Picker
Bottom-sheet to take/pick a photo and analyze it with AI (Premium).
App · Flutter · macromath_mobile
A reusable bottom-sheet to take or pick a photo and analyze it with the AiService.
It shows the source (camera/gallery), an analysis state with a thumbnail, and returns
a structured result. Because it uses AI, it is a Premium feature — the picker
calls the paywall automatically when needed.
Modes
| Mode | Use | Returns |
|---|---|---|
food | Meal | Foods with macros (name, quantity, unit, calories, protein, carbs, fat). |
pantry | Pantry | Simple items (name, quantity, unit, category, brand). |
shopping | Shopping list | Simple items. |
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
mode | PhotoAnalysisMode | — | food, pantry or shopping. |
hint | String? | null | Optional hint for the AI. |
Result — PhotoAnalysisResult
| Field | Type | Description |
|---|---|---|
mode | PhotoAnalysisMode | Mode used in the analysis. |
items | List<Map<String, dynamic>> | Detected items. |
confidence | double | Confidence (0–1). |
summary | String | Text summary of the analysis. |
isEmpty | bool | true if there were no detections. |
Usage
import 'package:macromath_mobile/presentation/widgets/photo_food_picker.dart';
final result = await showPhotoFoodPicker(
context,
mode: PhotoAnalysisMode.food,
);
if (result != null && !result.isEmpty) {
// add result.items to the meal
}Returns null if the user cancels or if they don't have Premium (the paywall is
shown in that case).