26 lines
722 B
Dart
26 lines
722 B
Dart
import 'package:flutter/services.dart';
|
|
|
|
class ShareIntentService {
|
|
factory ShareIntentService() {
|
|
_instance ??= ShareIntentService._internal();
|
|
return _instance!;
|
|
}
|
|
|
|
ShareIntentService._internal();
|
|
|
|
static ShareIntentService? _instance;
|
|
static const _platform = MethodChannel('app.channel.shared.data');
|
|
|
|
Future<String> getSharedMapsLink() async {
|
|
final String? sharedText = await _platform.invokeMethod('getSharedText');
|
|
if (sharedText != null && _isGoogleMapsLink(sharedText)) return sharedText;
|
|
return '';
|
|
}
|
|
|
|
bool _isGoogleMapsLink(String text) {
|
|
return text.contains('maps.google.com') ||
|
|
text.contains('maps.app.goo.gl') ||
|
|
text.contains('goo.gl/maps');
|
|
}
|
|
}
|