-
Notifications
You must be signed in to change notification settings - Fork 41
/
misc.dart
38 lines (30 loc) · 877 Bytes
/
misc.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import 'dart:io';
import 'package:flutter/services.dart';
class PlatformMiscMethods {
const PlatformMiscMethods._();
static const instance = PlatformMiscMethods._();
final _methodChannel = const MethodChannel('xyz.project.violet/misc');
Future<void> finishMainActivity() async {
if (!Platform.isAndroid) {
throw UnsupportedError('Android only');
}
await _methodChannel.invokeMethod('finishMainActivity');
}
Future<void> exportFile(
String filePath, {
required String mimeType,
required String fileNameToSaveAs,
}) async {
if (!Platform.isAndroid) {
throw UnsupportedError('Android only');
}
await _methodChannel.invokeMethod<String>(
'exportFile',
<String, dynamic>{
'filePath': filePath,
'mimeType': mimeType,
'fileNameToSaveAs': fileNameToSaveAs,
},
);
}
}