An AI-powered meal preparation app built with Flutter, Firebase AI, and modern architecture patterns.
- 📸 Image Analysis: Take photos or select images of food ingredients
- 🤖 AI-Powered Ingredient Recognition: Use Gemini to identify ingredients from images
- 🍳 Recipe Generation: Generate recipes based on identified ingredients and user notes
- 🎨 Recipe Image Creation: Generate professional food photography with Imagen
- 📱 Modern UI: Clean, Material 3 design with responsive layout
This Flutter app follows modern architectural patterns:
lib/data/
├── datasource/
│ └── ai_remote_data_source.dart # AI API calls (Gemini & Imagen)
├── repository/
│ └── ai_repository.dart # Repository pattern implementation
└── model/
└── recipe.dart # Recipe data model
lib/ui/
└── home/
├── home_page.dart # Main UI screen
├── cubit/
│ ├── home_cubit.dart # State management (BLoC/Cubit)
│ └── home_state.dart # UI state definitions
└── widgets/
├── home_ingredients_section.dart
├── home_recipe_section.dart
└── widgets.dart
lib/core/
├── di/
│ └── firebase_module.dart # DI for Firebase AI models
├── exceptions/
│ └── ai_exceptions.dart # Custom exception classes
├── theme/ # App theming
└── widgets/ # Reusable UI components
- Flutter: Cross-platform UI framework
- Dart: Programming language
- BLoC/Cubit: State management pattern (
flutter_bloc
) - Equatable: Value equality for state classes
- GetIt: Service locator for dependency injection
- Injectable: Code generation for DI
- Firebase Core: Firebase initialization
- Firebase AI: Gemini and Imagen model access
- Firebase App Check: App verification and security
- Image Picker: Camera and gallery integration
- Material 3: Modern Material Design
- GPT Markdown: Recipe content formatting
- Cupertino Icons: iOS-style icons
- Flutter SDK (3.8.0 or later)
- Firebase Project with AI Logic enabled
- Firebase AI API access (Gemini Developer API or Vertex AI)
-
Clone the repository
git clone <repository-url> cd firebase_ai_friendly_meals
-
Install dependencies
flutter pub get
-
Generate dependency injection code
dart run build_runner build
-
Configure Firebase
- Add your
google-services.json
(Android) andGoogleService-Info.plist
(iOS) - Enable Firebase AI Logic in your Firebase project
- Set up API keys for Gemini and Imagen models
- Add your
-
Run the app
flutter run
Handles direct API calls to Firebase AI services:
generateIngredients()
: Multimodal Gemini call with image inputgenerateRecipe()
: Text generation based on ingredients and notesgenerateRecipeImage()
: Imagen model for recipe photography
Provides a clean interface for the UI layer, abstracting the data source implementation.
Manages the home screen state using BLoC pattern:
- Image selection and preview
- Ingredient loading states
- Recipe generation workflow
- Error handling and validation
Immutable state class containing:
ingredients
: Current ingredient listnotes
: User-provided cooking notesselectedImage
: Selected image for analysisrecipe
: Generated recipe resultstatus
: Current view state (initial, loading, success, failure)errorMessage
: Error messages for user feedback
Responsive UI with sections for:
- Image capture/selection
- Ingredients display
- Notes input
- Recipe generation
- Results display
The app uses Firebase AI Logic to access:
- Gemini Models: For text generation and multimodal analysis
- Imagen Models: For high-quality recipe image generation
// Example Gemini call
final response = await _generativeModel.generateContent([
Content.text(prompt)
]);
// Example Imagen call
final imageResponse = await _imagenModel.generateImages(prompt);
Some features require code generation:
# Generate dependency injection code
dart run build_runner build
# Watch for changes during development
dart run build_runner watch
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is part of the Firebase Extended samples and follows the same licensing terms.
Built with ❤️ using Flutter and Firebase AI Logic