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/MealsScreen.dart

49 lines
1.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:meals/models/Meal.dart';
class MealsScreen extends StatelessWidget {
final String title;
final List<Meal> meals;
const MealsScreen({super.key, required this.title, required this.meals});
@override
Widget build(BuildContext context) {
final Widget content = meals.isEmpty
? Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'Oh, there is no meals right here.',
style: Theme.of(context).textTheme.headlineLarge!.copyWith(
color: Theme.of(context).colorScheme.onBackground,
),
),
const SizedBox(height: 16),
Text(
'Would you to try something else ?',
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
color: Theme.of(context).colorScheme.onBackground,
),
),
],
),
)
: ListView.builder(
itemBuilder: (BuildContext context, int index) {
return Text(meals[index].title);
},
itemCount: meals.length,
);
return Scaffold(
appBar: AppBar(
title: Text(title),
),
body: content,
);
}
}