sendData method
Implementation
Future<void> sendData(String? selectedId) async {
if (host == null || port == null) return;
final url = Uri.parse('http://$host:$port/scan');
try {
final response = await http.post(
url,
body: jsonEncode({'selectedId': selectedId}),
headers: {'Content-Type': 'application/json'},
);
connected = true;
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("Product Scanned Successfully")));
} catch (e) {
print('Error sending: $e');
}
notifyListeners();
}