diff --git a/flutter/lib/core/router/app_router.dart b/flutter/lib/core/router/app_router.dart index b3bf9b73..07a81d69 100644 --- a/flutter/lib/core/router/app_router.dart +++ b/flutter/lib/core/router/app_router.dart @@ -68,8 +68,20 @@ final appRouterProvider = Provider((ref) { GoRoute( path: '/recipes/create', builder: (context, state) { - final initialMarkdown = state.extra as String?; - return CreateRecipeScreen(initialMarkdown: initialMarkdown); + final extra = state.extra; + String? initialMarkdown; + String? initialImageUrl; + if (extra is Map) { + initialMarkdown = extra['markdown'] as String?; + initialImageUrl = extra['imageUrl'] as String?; + } else if (extra is String) { + // Backwards-compat: plain string means markdown only. + initialMarkdown = extra; + } + return CreateRecipeScreen( + initialMarkdown: initialMarkdown, + initialImageUrl: initialImageUrl, + ); }, ), GoRoute( diff --git a/flutter/lib/features/import/presentation/recipe_import_tab.dart b/flutter/lib/features/import/presentation/recipe_import_tab.dart index 28fffd48..f746f487 100644 --- a/flutter/lib/features/import/presentation/recipe_import_tab.dart +++ b/flutter/lib/features/import/presentation/recipe_import_tab.dart @@ -78,8 +78,11 @@ class _RecipeImportTabState extends ConsumerState { ); if (!mounted) return; - // Pass markdown as GoRouter extra — CreateRecipeScreen picks it up. - context.push('/recipes/create', extra: result.markdown); + // Pass both markdown and imageUrl so CreateRecipeScreen can pre-fill both. + context.push('/recipes/create', extra: { + 'markdown': result.markdown, + 'imageUrl': result.imageUrl, + }); } catch (e) { if (!mounted) return; setState(() => _error = mapErrorToUserMessage(e, context)); diff --git a/flutter/lib/features/recipes/presentation/create_recipe_screen.dart b/flutter/lib/features/recipes/presentation/create_recipe_screen.dart index f4f62558..2d4116a7 100644 --- a/flutter/lib/features/recipes/presentation/create_recipe_screen.dart +++ b/flutter/lib/features/recipes/presentation/create_recipe_screen.dart @@ -14,7 +14,14 @@ class CreateRecipeScreen extends ConsumerStatefulWidget { /// Optional markdown to pre-fill the input field, e.g. from import. final String? initialMarkdown; - const CreateRecipeScreen({super.key, this.initialMarkdown}); + /// Optional image URL pre-filled from a quick-import result. + final String? initialImageUrl; + + const CreateRecipeScreen({ + super.key, + this.initialMarkdown, + this.initialImageUrl, + }); @override ConsumerState createState() => @@ -143,6 +150,8 @@ class _CreateRecipeScreenState extends ConsumerState { if (servingsRaw != null) 'servings': servingsRaw, if (_parsed!.instructions != null) 'instructions': _parsed!.instructions, + if (widget.initialImageUrl != null && widget.initialImageUrl!.isNotEmpty) + 'imageUrl': widget.initialImageUrl, 'ingredients': ingredients, }, token: token,