monorepo/dialer/lib/domain/services/message_service.dart
AlexisDanlos 4ecf7c546b
All checks were successful
/ mirror (push) Successful in 5s
/ build (push) Successful in 10m40s
/ build-stealth (push) Successful in 10m34s
feat: add MessageService for sending SMS and integrate into ContactModal
2025-05-11 12:11:32 +02:00

19 lines
555 B
Dart

import 'dart:io' show Platform;
import 'package:flutter/foundation.dart';
import 'package:url_launcher/url_launcher.dart';
/// A service to handle sending SMS messages using the url_launcher package.
class MessageService {
/// Launches the SMS dialer for the given [phoneNumber].
Future<void> sendSms(String phoneNumber) async {
// Sanitize number (keep only digits and plus sign)
final sanitized = phoneNumber.replaceAll(RegExp(r'[^0-9+]'), '');
Uri uri;
uri = Uri(scheme: 'sms', path: sanitized);
await launchUrl(uri);
}
}