Flutter-Ernaehrungsapp/lib/android/pages/nav_pages/meal_plan_page.dart

86 lines
2.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:hive_flutter/adapters.dart';
import '../../components/card_component.dart';
import '../../models/food.dart';
class MealPlanPage extends StatefulWidget {
final String title;
final Color backgroundColor = const Color(0xff47a44b);
const MealPlanPage({Key? key, required this.title}) : super(key: key);
String get getTitle => title;
@override
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
return getTitle;
}
@override
Widget build(BuildContext context) {
return Scaffold();
}
@override
State<StatefulWidget> createState() => _MealPlanState();
}
class _MealPlanState extends State<MealPlanPage> {
List<Food> castDynamicToListFood(List<dynamic> dynamicList) {
List<Food> foodList = [];
for (Food element in dynamicList) {
foodList.add(element);
}
return foodList;
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SizedBox(
width: double.infinity,
height: double.infinity,
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [Color(0xff000000), Color(0xff47a44b)],
stops: [0.1, 5],
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
)),
child: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 0),
child: Column(
children: [
ValueListenableBuilder(
valueListenable: Hive.box("TODAY").listenable(),
builder: (context, box, widget) {
return ListView.builder(
primary: false,
shrinkWrap: true,
itemCount: box.keys.length,
itemBuilder: (context, i) {
if(box.keyAt(i).toString() == "DATE"){
return const SizedBox.shrink();
}else{
return CardComponent(
eatingMealName: box.keyAt(i).toString(),
selectedMeal: castDynamicToListFood(
box.getAt(i))
);
}
}
);
}),
],
),
)),
));
}
}