added provider to createRecipePage

This commit is contained in:
2025-02-11 15:09:14 +01:00
parent e8de4879eb
commit 0b58a7a794

View File

@@ -1,5 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../services/providers/recipe_provider.dart';
import 'create_recipe_pages/ingredients_page.dart'; import 'create_recipe_pages/ingredients_page.dart';
import 'create_recipe_pages/metadata_page.dart'; import 'create_recipe_pages/metadata_page.dart';
import 'create_recipe_pages/steps_page.dart'; import 'create_recipe_pages/steps_page.dart';
@@ -21,6 +23,8 @@ class _CreateRecipePageState extends State<CreateRecipePage> {
const StepsPage(), const StepsPage(),
]; ];
late RecipeProvider _recipeProvider;
final List<NavigationDestination> _destinations = [ final List<NavigationDestination> _destinations = [
NavigationDestination( NavigationDestination(
icon: Icon(Icons.list), icon: Icon(Icons.list),
@@ -38,6 +42,7 @@ class _CreateRecipePageState extends State<CreateRecipePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
_recipeProvider = context.watch<RecipeProvider>();
return Scaffold( return Scaffold(
appBar: AppBar(), appBar: AppBar(),
bottomNavigationBar: NavigationBar( bottomNavigationBar: NavigationBar(
@@ -47,7 +52,16 @@ class _CreateRecipePageState extends State<CreateRecipePage> {
_currentPageIndex = value; _currentPageIndex = value;
}), }),
), ),
body: _pages.elementAt(_currentPageIndex), body: IndexedStack(
index: _currentPageIndex,
children: _pages,
),
); );
} }
@override
void dispose() {
super.dispose();
_recipeProvider.disposeRecipe();
}
} }