| 1 | import 'package:flutter/services.dart'; |
| 2 | import 'package:json_annotation/json_annotation.dart'; |
| 3 | |
| 4 | part 'wear_os.g.dart'; |
| 5 | |
| 6 | @JsonSerializable() |
| 7 | class WearOSDevice { |
| 8 | final String id; |
| 9 | final String displayName; |
| 10 | final bool isNearby; |
| 11 | |
| 12 | WearOSDevice({ |
| 13 | required this.id, |
| 14 | required this.displayName, |
| 15 | required this.isNearby, |
| 16 | }); |
| 17 | |
| 18 | factory WearOSDevice.fromJson( |
| 19 | toJson() => _$WearOSDeviceToJson( |
| 20 | } |
| 21 | |
| 22 | class WearOSService { |
| 23 | static const MethodChannel |
| 24 | |
| 25 | /// Get list of connected Wear OS devices |
| 26 | Future<List<WearOSDevice |
| 27 | try { |
| 28 | final List<Object |
| 29 | 'getConnectedWearables', |
| 30 | ); |
| 31 | final List<Map |
| 32 | return result.map((json) => |
| 33 | } on PlatformException catch (e) { |
| 34 | print('Error getting connected devices: ${e. |
| 35 | return []; |
| 36 | } |
| 37 | } |
| 38 | } |