openChat method

  1. @override
Future<void> openChat({
  1. required String phone,
  2. required String text,
})
override

Opens a WhatsApp chat with phone using the Click-to-Chat URL (https://wa.me/{phone}?text={text}).

Unlike shareToChat, this method works for any phone number regardless of whether the user has previously chatted with that number. However, it only supports text — images cannot be attached.

Throws a PlatformException when no app can handle the URL.

Implementation

@override
Future<void> openChat({required String phone, required String text}) async {
  await methodChannel.invokeMethod<void>('openChat', <String, dynamic>{
    'phone': phone,
    'text': text,
  });
}