sendKml method

Future<void> sendKml(
  1. KMLModel kml, {
  2. List<Map<String, String>> images = const [],
})

Sends a the given kml to the Liquid Galaxy system.

It also accepts a List of images represents by Maps. The images must have the following pattern:

[
  {
    'name': 'img-1.png',
    'path': 'path/to/img-1'
  },
  {
    'name': 'img-2.png',
    'path': 'path/to/img-2'
  }
]

Implementation

Future<void> sendKml(KMLModel kml,
    {List<Map<String, String>> images = const []}) async {
  final fileName = '${kml.name}.kml';

  for (var img in images) {
    final image = await _fileService.createImage(img['name']!, img['path']!);
    String imageName = img['name']!;
    try {
      await _sshData.uploadKml(image, imageName);
    } catch (e) {
      // ignore: avoid_print
      print(e);
    }
  }
  try {
    final kmlFile = await _fileService.createFile(fileName, kml.body);
    await _sshData.uploadKml(kmlFile, fileName);
    await _sshData.execute('echo "$_url/$fileName" > /var/www/html/kmls.txt');
  } catch (e) {
    // ignore: avoid_print
    print(e);
  }
}