Skip to content

Commit f2a8f7e

Browse files
committed
improve the example
1 parent 2ed1cac commit f2a8f7e

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

example/lib/main.dart

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'package:flutter/material.dart';
2-
import 'package:emailjs/emailjs.dart';
2+
import 'package:emailjs/emailjs.dart' as emailjs;
33

44
void main() {
55
runApp(const App());
@@ -31,22 +31,26 @@ class HomePage extends StatefulWidget {
3131
class _HomePageState extends State<HomePage> {
3232
void _sendEmail() async {
3333
try {
34-
await EmailJS.send(
35-
'<YOUR_SERVICE_ID>',
36-
'<YOUR_TEMPLATE_ID>',
34+
await emailjs.send(
35+
'YOUR_SERVICE_ID',
36+
'YOUR_TEMPLATE_ID',
3737
{
38-
'user_email': '[email protected]',
38+
'to_email': '[email protected]',
3939
'message': 'Hi',
4040
},
41-
const Options(
42-
publicKey: '<YOUR_PUBLIC_KEY>',
43-
privateKey: '<YOUR_PRIVATE_KEY>',
41+
const emailjs.Options(
42+
publicKey: 'YOUR_PUBLIC_KEY',
43+
privateKey: 'YOUR_PRIVATE_KEY',
44+
limitRate: const emailjs.LimitRate(
45+
id: 'app',
46+
throttle: 10000,
47+
)
4448
),
4549
);
4650
print('SUCCESS!');
4751
} catch (error) {
48-
if (error is EmailJSResponseStatus) {
49-
print('ERROR... ${error.status}: ${error.text}');
52+
if (error is emailjs.EmailJSResponseStatus) {
53+
print('ERROR... $error');
5054
}
5155
print(error.toString());
5256
}

0 commit comments

Comments
 (0)