36 lines
928 B
Dart
36 lines
928 B
Dart
part of '../app/app.dart';
|
|
|
|
class SessionGate extends StatefulWidget {
|
|
const SessionGate({super.key});
|
|
|
|
@override
|
|
State<SessionGate> createState() => _SessionGateState();
|
|
}
|
|
|
|
class _SessionGateState extends State<SessionGate> {
|
|
late final Future<SessionData> _sessionFuture;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_sessionFuture = SessionStore.session();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return FutureBuilder<SessionData>(
|
|
future: _sessionFuture,
|
|
builder: (context, snapshot) {
|
|
if (!snapshot.hasData &&
|
|
snapshot.connectionState != ConnectionState.done) {
|
|
return const LoadingScreen();
|
|
}
|
|
final session = snapshot.data ?? const SessionData();
|
|
return session.token == null
|
|
? const LoginScreen()
|
|
: DashboardScreen(token: session.token!, baseUrl: session.baseUrl);
|
|
},
|
|
);
|
|
}
|
|
}
|