38 lines
1.2 KiB
Dart
38 lines
1.2 KiB
Dart
|
import 'package:ernaehrung/pages/search_food/sub_components/search.dart';
|
||
|
import 'package:flutter/material.dart';
|
||
|
import '../../models/food.dart';
|
||
|
import '../../models/food_dto.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) {
|
||
|
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 Center(
|
||
|
child: CircularProgressIndicator(), // Loading animation
|
||
|
);
|
||
|
}
|
||
|
})
|
||
|
));
|
||
|
}
|
||
|
}
|