feat(flutter): connection-error banner + 401-clears-session interceptor
ApiClient.buildDio takes on401; the library's dioProvider wires it to the auth controller's clearSession. The router redirect already handles navigation away from authed screens once the session goes null. HomeScreen surfaces the banner on connection_refused with Retry + Change URL.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../theme/theme_extension.dart';
|
||||
|
||||
class ConnectionErrorBanner extends StatelessWidget {
|
||||
const ConnectionErrorBanner({required this.onRetry, super.key});
|
||||
final VoidCallback onRetry;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final fs = Theme.of(context).extension<FabledSwordTheme>()!;
|
||||
return Container(
|
||||
color: fs.iron,
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Row(children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"Couldn't reach the server.",
|
||||
style: TextStyle(color: fs.parchment),
|
||||
),
|
||||
),
|
||||
TextButton(onPressed: onRetry, child: const Text('Retry')),
|
||||
TextButton(
|
||||
onPressed: () => context.go('/server-url'),
|
||||
child: const Text('Change URL'),
|
||||
),
|
||||
]),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user