You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
meals/lib/screens/meal_details.dart

81 lines
2.5 KiB
Dart

import 'package:flutter/material.dart';
import '../models/Meal.dart';
class MealDetailScreen extends StatelessWidget {
final Meal meal;
final void Function(Meal meal) onToggleFavorite;
const MealDetailScreen(
{Key? key, required this.meal, required this.onToggleFavorite})
: super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(meal.title),
actions: [
IconButton(
onPressed: () => onToggleFavorite(meal),
icon: const Icon(Icons.star))
],
),
body: SingleChildScrollView(
child: Column(
children: [
Image.network(
meal.imageUrl,
width: double.infinity,
height: 300,
fit: BoxFit.cover,
),
const SizedBox(
height: 14,
),
Text(
'Ingredients',
style: Theme.of(context).textTheme.titleLarge!.copyWith(
color: Theme.of(context).colorScheme.primary,
fontWeight: FontWeight.bold,
),
),
const SizedBox(
height: 14,
),
for (final ingredient in meal.ingredients)
Text(
ingredient,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: Theme.of(context).colorScheme.onBackground),
),
const SizedBox(
height: 14,
),
Text(
'Steps',
style: Theme.of(context).textTheme.titleLarge!.copyWith(
color: Theme.of(context).colorScheme.primary,
fontWeight: FontWeight.bold,
),
),
const SizedBox(
height: 14,
),
for (final step in meal.steps)
Padding(
padding:
const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
child: Text(
step,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: Theme.of(context).colorScheme.onBackground),
),
),
],
),
));
}
}