import 'package:aves/model/catalog_metadata.dart'; import 'package:aves/model/metadata_storage_service.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; class MetadataService { static const platform = const MethodChannel('deckers.thibault/aves/metadata'); // return Map> (map of directories, each directory being a map of metadata label and value description) static Future getAllMetadata(String path) async { try { final result = await platform.invokeMethod('getAllMetadata', { 'path': path, }); return result as Map; } on PlatformException catch (e) { debugPrint('getAllMetadata failed with exception=${e.message}'); } return Map(); } static Future getCatalogMetadata(int contentId, String path) async { CatalogMetadata metadata; try { // return map with: // 'dateMillis': date taken in milliseconds since Epoch (long) // 'latitude': latitude (double) // 'longitude': longitude (double) // 'xmpSubjects': space separated XMP subjects (string) final result = await platform.invokeMethod('getCatalogMetadata', { 'path': path, }) as Map; result['contentId'] = contentId; metadata = CatalogMetadata.fromMap(result); metadataDb.insert(metadata); return metadata; } on PlatformException catch (e) { debugPrint('getCatalogMetadata failed with exception=${e.message}'); } return null; } // return map with string descriptions for: 'aperture' 'exposureTime' 'focalLength' 'iso' static Future getOverlayMetadata(String path) async { try { final result = await platform.invokeMethod('getOverlayMetadata', { 'path': path, }); return result as Map; } on PlatformException catch (e) { debugPrint('getOverlayMetadata failed with exception=${e.message}'); } return Map(); } }