summaryrefslogtreecommitdiff
path: root/lib/services/share_service.dart
blob: 36eb7af61e4c9859347c36ecf767b35f8a65d743 (plain)
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
import 'dart:io' show Platform;

import 'package:flutter/services.dart';

class ShareService {
  static const _channel = MethodChannel('org.buetow.quicklog/share');

  static Future<String?> readSharedTextFromCache() async {
    if (!Platform.isAndroid) return null;
    try {
      return await _channel.invokeMethod<String>('readSharedTextFromCache');
    } on MissingPluginException {
      return null;
    }
  }

  static Future<void> clearSharedTextCache() async {
    if (!Platform.isAndroid) return;
    try {
      await _channel.invokeMethod<void>('clearSharedTextCache');
    } on MissingPluginException {
      // No-op: channel not registered (e.g. running on a non-Android target).
    }
  }
}