You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Restarted application in 453ms.
flutter: HTTP Code: null
flutter: API Error: null
flutter: Request Error: ClientException: Failed to parse header value
flutter: API Response: null
my code,
import 'package:flutter/material.dart';
import 'package:whatsapp/whatsapp.dart';
void main() => runApp(MaterialApp(home: Home()));
class Home extends StatefulWidget {
const Home({super.key});
@override
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> {
late WhatsApp whatsapp; // Declare as late to initialize later
final String accessToken1 =
'myaccesstoken';
final String fromNumberId = 'myphonenumberid';
@override
void initState() {
super.initState();
// Initialize WhatsApp instance here
whatsapp = WhatsApp(accessToken1, fromNumberId);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: [
TextButton(
onPressed: () async {
if (whatsapp != null) {
try {
var res = await whatsapp.sendMessage(
phoneNumber: '+919019.....',
text: 'Hello from Flutter!',
previewUrl: true,
);
if (res.isSuccess()) {
debugPrint('Message ID: ${res.getMessageId()}');
debugPrint('Message sent to: ${res.getPhoneNumber()}');
debugPrint('API Response: ${res.getResponse().toString()}');
} else {
debugPrint('HTTP Code: ${res.getHttpCode()}');
debugPrint('API Error: ${res.getErrorMessage()}');
debugPrint('Request Error: ${res.getError()}');
debugPrint('API Response: ${res.getResponse().toString()}');
}
} catch (e) {
debugPrint('Error: $e');
}
} else {
debugPrint('WhatsApp is not initialized!');
}
},
child: const Text("Send Message"),
),
],
),
);
}
}
could you please someone help me to sort out the issue?
The text was updated successfully, but these errors were encountered:
Hi Dear
getting
this error
Restarted application in 453ms.
flutter: HTTP Code: null
flutter: API Error: null
flutter: Request Error: ClientException: Failed to parse header value
flutter: API Response: null
my code,
could you please someone help me to sort out the issue?
The text was updated successfully, but these errors were encountered: