getDevices method

Future<List> getDevices(
  1. String host, [
  2. int? scannerType
])

Fetches the list of available scanners from Dynamic Web TWAIN Service.

host - The host server URL.

Returns a List<dynamic> containing information about available scanners.

Implementation

Future<List<dynamic>> getDevices(String host, [int? scannerType]) async {
  String url = '$host/api/device/scanners';
  if (scannerType != null) {
    url += '?type=$scannerType';
  }

  try {
    final response = await http.get(Uri.parse(url));
    if (response.statusCode == 200) {
      return json.decode(response.body);
    }
  } catch (error) {}
  return [];
}