From 08b82bd6694b7c26451459b51c897efc9e123eef Mon Sep 17 00:00:00 2001 From: Oliver Bagge Date: Fri, 2 Jan 2026 16:45:18 +0100 Subject: [PATCH 1/3] show error message in platform dialog when connection fails/device is unsupported --- .../lib/models/bluetooth_auto_connector.dart | 3 +- .../widgets/devices/connect_devices_page.dart | 29 ++++++++++++++++++- open_wearable/pubspec.lock | 16 +++++----- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/open_wearable/lib/models/bluetooth_auto_connector.dart b/open_wearable/lib/models/bluetooth_auto_connector.dart index f1c984fd..5c5913bb 100644 --- a/open_wearable/lib/models/bluetooth_auto_connector.dart +++ b/open_wearable/lib/models/bluetooth_auto_connector.dart @@ -141,7 +141,8 @@ class BluetoothAutoConnector { .connectToDevice(device) .then(onWearableConnected) .catchError((e) { - logger.e("Failed to connect to ${device.name}: $e"); + logger.e( + "Failed to connect to ${device.id}: ${wearableManager.deviceErrorMessage(e, device.name)}"); }).whenComplete(() { _isConnecting = false; }); diff --git a/open_wearable/lib/widgets/devices/connect_devices_page.dart b/open_wearable/lib/widgets/devices/connect_devices_page.dart index 5c42edd3..4fe166f7 100644 --- a/open_wearable/lib/widgets/devices/connect_devices_page.dart +++ b/open_wearable/lib/widgets/devices/connect_devices_page.dart @@ -132,7 +132,34 @@ class _ConnectDevicesPageState extends State { discoveredDevices.remove(device); }); } catch (e) { - logger.e('Failed to connect to device: ${device.name}, error: $e'); + final _wearableEventController = + StreamController.broadcast(); + final wearableEventController = + context.read().wearableEventController; + String message = _wearableManager.deviceErrorMessage(e, device.name); + logger.e('Failed to connect to device: ${device.name}, error: $message'); + _wearableEventController.add( + WearableErrorEvent( + wearable: wearable, + errorMessage: 'Failed to synchronize time with ${wearable.name}: $e', + description: 'Failed to synchronize time for ${wearable.name}', + ), + ); + if (context.mounted) { + showPlatformDialog( + context: context, + builder: (context) => PlatformAlertDialog( + title: PlatformText('Connection Error'), + content: PlatformText(message), + actions: [ + PlatformDialogAction( + onPressed: () => Navigator.of(context).pop(), + child: PlatformText('OK'), + ), + ], + ), + ); + } } finally { setState(() { connectingDevices.remove(device.id); diff --git a/open_wearable/pubspec.lock b/open_wearable/pubspec.lock index 1a527f13..78870ac3 100644 --- a/open_wearable/pubspec.lock +++ b/open_wearable/pubspec.lock @@ -45,10 +45,10 @@ packages: dependency: transitive description: name: characters - sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.4.1" clock: dependency: transitive description: @@ -420,18 +420,18 @@ packages: dependency: transitive description: name: matcher - sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6" url: "https://pub.dev" source: hosted - version: "0.12.17" + version: "0.12.18" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" url: "https://pub.dev" source: hosted - version: "0.11.1" + version: "0.13.0" mcumgr_flutter: dependency: "direct main" description: @@ -825,10 +825,10 @@ packages: dependency: transitive description: name: test_api - sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 + sha256: "19a78f63e83d3a61f00826d09bc2f60e191bf3504183c001262be6ac75589fb8" url: "https://pub.dev" source: hosted - version: "0.7.7" + version: "0.7.8" tuple: dependency: transitive description: From 29ff50b10808867ca72444fb606ff64884e316a8 Mon Sep 17 00:00:00 2001 From: Oliver Bagge Date: Fri, 2 Jan 2026 16:47:29 +0100 Subject: [PATCH 2/3] remove faulty code --- .../lib/widgets/devices/connect_devices_page.dart | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/open_wearable/lib/widgets/devices/connect_devices_page.dart b/open_wearable/lib/widgets/devices/connect_devices_page.dart index 4fe166f7..96bc20ef 100644 --- a/open_wearable/lib/widgets/devices/connect_devices_page.dart +++ b/open_wearable/lib/widgets/devices/connect_devices_page.dart @@ -132,19 +132,8 @@ class _ConnectDevicesPageState extends State { discoveredDevices.remove(device); }); } catch (e) { - final _wearableEventController = - StreamController.broadcast(); - final wearableEventController = - context.read().wearableEventController; String message = _wearableManager.deviceErrorMessage(e, device.name); logger.e('Failed to connect to device: ${device.name}, error: $message'); - _wearableEventController.add( - WearableErrorEvent( - wearable: wearable, - errorMessage: 'Failed to synchronize time with ${wearable.name}: $e', - description: 'Failed to synchronize time for ${wearable.name}', - ), - ); if (context.mounted) { showPlatformDialog( context: context, From 139c6b87c50a63658279bdc1440d8461bb9530c2 Mon Sep 17 00:00:00 2001 From: Oliver Bagge Date: Fri, 2 Jan 2026 16:49:19 +0100 Subject: [PATCH 3/3] add trailing comma --- open_wearable/lib/models/bluetooth_auto_connector.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/open_wearable/lib/models/bluetooth_auto_connector.dart b/open_wearable/lib/models/bluetooth_auto_connector.dart index 5c5913bb..bc68d6b8 100644 --- a/open_wearable/lib/models/bluetooth_auto_connector.dart +++ b/open_wearable/lib/models/bluetooth_auto_connector.dart @@ -142,7 +142,8 @@ class BluetoothAutoConnector { .then(onWearableConnected) .catchError((e) { logger.e( - "Failed to connect to ${device.id}: ${wearableManager.deviceErrorMessage(e, device.name)}"); + "Failed to connect to ${device.id}: ${wearableManager.deviceErrorMessage(e, device.name)}", + ); }).whenComplete(() { _isConnecting = false; });