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:
25
ai_recipe_generation/lib/services/firestore.dart
Normal file
25
ai_recipe_generation/lib/services/firestore.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
|
||||
import '../features/recipes/recipe_model.dart';
|
||||
|
||||
const recipePath = '/recipes';
|
||||
final firestore = FirebaseFirestore.instance;
|
||||
|
||||
class FirestoreService {
|
||||
static Future<Null> saveRecipe(Recipe recipe) async {
|
||||
await firestore
|
||||
.collection(recipePath)
|
||||
.doc(recipe.id)
|
||||
.set(recipe.toFirestore());
|
||||
}
|
||||
|
||||
static Future<Null> deleteRecipe(Recipe recipe) async {
|
||||
await firestore.doc("$recipePath/${recipe.id}").delete();
|
||||
}
|
||||
|
||||
static Future<Null> updateRecipe(Recipe recipe) async {
|
||||
await firestore
|
||||
.doc("$recipePath/${recipe.id}")
|
||||
.update(recipe.toFirestore());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user