fix reconnect logic
This commit is contained in:
@@ -89,6 +89,20 @@ extension LKExampleExt on BuildContext {
|
||||
),
|
||||
);
|
||||
|
||||
Future<void> showReconnectSuccessDialog() => showDialog<void>(
|
||||
context: this,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: const Text('Reconnect'),
|
||||
content: const Text('Reconnection was successful.'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx),
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Future<bool?> showSendDataDialog() => showDialog<bool>(
|
||||
context: this,
|
||||
builder: (ctx) => AlertDialog(
|
||||
|
||||
@@ -126,7 +126,14 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
|
||||
void _onTapReconnect() async {
|
||||
final result = await context.showReconnectDialog();
|
||||
if (result == true) await widget.room.reconnect();
|
||||
if (result == true) {
|
||||
try {
|
||||
await widget.room.reconnect();
|
||||
await context.showReconnectSuccessDialog();
|
||||
} catch (error) {
|
||||
await context.showErrorDialog(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _onTapSendData() async {
|
||||
|
||||
Reference in New Issue
Block a user