57 lines
1.2 KiB
Dart
57 lines
1.2 KiB
Dart
|
import 'package:flutter/material.dart';
|
||
|
import 'package:outbag_app/backend/room.dart';
|
||
|
|
||
|
class ShoppingListPage extends StatefulWidget {
|
||
|
final RoomInfo? info;
|
||
|
final Room? room;
|
||
|
|
||
|
const ShoppingListPage(this.room, this.info, {super.key});
|
||
|
|
||
|
@override
|
||
|
State<StatefulWidget> createState() => _ShoppingListPageState();
|
||
|
}
|
||
|
|
||
|
class _ShoppingListPageState extends State<ShoppingListPage> {
|
||
|
List<ShoppingListItem> list = [];
|
||
|
|
||
|
void loadData() async {
|
||
|
//bool foundData = false;
|
||
|
|
||
|
// TODO: 1. load data from disk (if available)
|
||
|
// NOTE: errors do not matter,
|
||
|
// hopefully the network request will succeed
|
||
|
try {
|
||
|
//List<ShoppingListItem> list = await ShoppingListItem.getAllFromDisk();
|
||
|
//setState(() {
|
||
|
// this.list = list;
|
||
|
//})
|
||
|
|
||
|
//foundData = true;
|
||
|
} catch (_) {}
|
||
|
|
||
|
// TODO: 2. load data from web
|
||
|
|
||
|
// NOTE: might want to close room
|
||
|
// or show snackbar if no data is available
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
void initState() {
|
||
|
super.initState();
|
||
|
|
||
|
loadData();
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return ListView.builder(
|
||
|
itemBuilder: (ctx, index) {
|
||
|
final item = list[index];
|
||
|
|
||
|
return ListTile();
|
||
|
},
|
||
|
itemCount: list.length,
|
||
|
);
|
||
|
}
|
||
|
}
|