36 lines
1.1 KiB
Dart
36 lines
1.1 KiB
Dart
|
import 'package:ernaehrung/components/search_component.dart';
|
||
|
import 'package:ernaehrung/models/food.dart';
|
||
|
import 'package:ernaehrung/models/food_dto.dart';
|
||
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
class SearchFoodPage extends StatefulWidget {
|
||
|
final String cardName;
|
||
|
const SearchFoodPage(this.cardName, {Key? key}) : super(key: key);
|
||
|
|
||
|
@override
|
||
|
State<SearchFoodPage> createState() => _SearchFoodPageState();
|
||
|
}
|
||
|
|
||
|
class _SearchFoodPageState extends State<SearchFoodPage> {
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
print(widget.cardName);
|
||
|
return SafeArea(
|
||
|
top: true,
|
||
|
child: Scaffold(
|
||
|
extendBodyBehindAppBar: false,
|
||
|
extendBody: false,
|
||
|
resizeToAvoidBottomInset: false,
|
||
|
body: FutureBuilder(
|
||
|
future: FoodDTO.readJson(),
|
||
|
builder: (BuildContext context, AsyncSnapshot<List<Food>> snapshot) {
|
||
|
if (snapshot.hasData) {
|
||
|
return SearchComponent(snapshot.data!, widget.cardName);
|
||
|
}else {
|
||
|
return const Placeholder();
|
||
|
}
|
||
|
})));
|
||
|
}
|
||
|
}
|