aves/lib/services/viewer_service.dart

27 lines
857 B
Dart

import 'package:aves/services/services.dart';
import 'package:flutter/services.dart';
class ViewerService {
static const platform = MethodChannel('deckers.thibault/aves/viewer');
static Future<Map<String, dynamic>> getIntentData() async {
try {
// returns nullable map with 'action' and possibly 'uri' 'mimeType'
final result = await platform.invokeMethod('getIntentData');
if (result != null) return (result as Map).cast<String, dynamic>();
} on PlatformException catch (e) {
await reportService.recordChannelError('getIntentData', e);
}
return {};
}
static Future<void> pick(String uri) async {
try {
await platform.invokeMethod('pick', <String, dynamic>{
'uri': uri,
});
} on PlatformException catch (e) {
await reportService.recordChannelError('pick', e);
}
}
}