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 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); } }