convert to dao calls, prep for migration strategy and first start db seed
This commit is contained in:
@ -1,19 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:sendtrain/database/daos/sessions_dao.dart';
|
||||
import 'package:sendtrain/database/database.dart';
|
||||
import '../widgets/session_card.dart';
|
||||
|
||||
class SessionsScreen extends StatelessWidget {
|
||||
final AppDatabase database = AppDatabase();
|
||||
SessionsScreen({super.key});
|
||||
const SessionsScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder<List<Session>>(
|
||||
future: SessionsDao(database).all(),
|
||||
future: SessionsDao(Provider.of<AppDatabase>(context)).all(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
database.close();
|
||||
final sessions = snapshot.data!;
|
||||
final pending = sessions.where((session) =>
|
||||
session.status == SessionStatus.completed ||
|
||||
@ -28,8 +27,6 @@ class SessionsScreen extends StatelessWidget {
|
||||
Widget upcomingSession = SessionCard(session: upcoming);
|
||||
Widget currentSession = SessionCard(session: current);
|
||||
|
||||
database.close();
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
@ -66,7 +63,13 @@ class SessionsScreen extends StatelessWidget {
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return const CircularProgressIndicator();
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
child: SizedBox(
|
||||
height: 50.0,
|
||||
width: 50.0,
|
||||
child: CircularProgressIndicator(),
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user