Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
medapp_eksad
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qorri_di
medapp_eksad
Commits
3b8b2765
Commit
3b8b2765
authored
Sep 01, 2022
by
qorri_di
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consume API
- consume api
parent
33b15759
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
58 deletions
+12
-58
contact_api.dart
lib/api/contact_api.dart
+6
-6
contact_us2.dart
lib/screen/contact_us/contact_us2.dart
+3
-26
small_contact_us2.dart
lib/screen_small/small_contact/small_contact_us2.dart
+3
-26
No files found.
lib/api/contact_api.dart
View file @
3b8b2765
...
...
@@ -3,7 +3,7 @@ import 'dart:convert';
import
'package:http/http.dart'
as
http
;
import
'package:medapp_eksad/model/contact_model.dart'
;
Future
<
bool
>
savecontact
(
nama
,
email
,
nohp
,
message
)
async
{
Future
savecontact
(
nama
,
email
,
nohp
,
message
)
async
{
final
response
=
await
http
.
post
(
Uri
.
parse
(
'http://10.107.121.210:8081/medapp/v1/api/contact/save'
),
body:
jsonEncode
({
...
...
@@ -14,11 +14,11 @@ Future<bool> savecontact(nama, email, nohp, message) async {
headers:
{
'Content-type'
:
'application/json; charset=UTF-8'
,
});
if
(
response
.
statusCode
==
200
)
{
return
true
;
}
else
{
return
false
;
}
//
if (response.statusCode == 200) {
//
return true;
//
} else {
//
return false;
//
}
}
Future
<
List
<
contact
>>
showcontact
()
async
{
...
...
lib/screen/contact_us/contact_us2.dart
View file @
3b8b2765
...
...
@@ -4,6 +4,7 @@ import 'package:google_fonts/google_fonts.dart';
// import 'package:mcs_flutter/const/conts.dart';
import
'dart:convert'
;
import
'package:http/http.dart'
as
http
;
import
'package:medapp_eksad/api/contact_api.dart'
;
import
'package:medapp_eksad/widget/button_color.dart'
;
class
ContactUs2
extends
StatelessWidget
{
...
...
@@ -251,10 +252,10 @@ class ContactUs2 extends StatelessWidget {
style:
Btn_Submit
(),
onPressed:
()
async
{
if
(
_formKey
.
currentState
!.
validate
())
{
final
response
=
await
SendEmail
(
final
response
=
await
savecontact
(
nameController
.
value
.
text
,
phoneController
.
value
.
text
,
emailController
.
value
.
text
,
phoneController
.
value
.
text
,
messageController
.
value
.
text
);
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
response
==
200
...
...
@@ -289,28 +290,4 @@ class ContactUs2 extends StatelessWidget {
),
);
}
Future
SendEmail
(
String
name
,
String
phone
,
String
email
,
String
message
)
async
{
final
url
=
Uri
.
parse
(
'https://api.emailjs.com/api/v1.0/email/send'
);
const
serviceId
=
'service_wava70j'
;
const
templateId
=
'template_koc73cj'
;
const
userId
=
'h4BmDnyWlm3OziBDx'
;
final
response
=
await
http
.
post
(
url
,
headers:
{
'Content-Type'
:
'application/json'
},
//This line makes sure it works for all platforms.
body:
json
.
encode
({
'service_id'
:
serviceId
,
'template_id'
:
templateId
,
'user_id'
:
userId
,
'template_params'
:
{
'from_name'
:
name
,
'from_phone'
:
phone
,
'to_email'
:
email
,
'message'
:
message
}
}));
return
response
.
statusCode
;
}
}
lib/screen_small/small_contact/small_contact_us2.dart
View file @
3b8b2765
...
...
@@ -4,6 +4,7 @@ import 'package:google_fonts/google_fonts.dart';
// import 'package:mcs_flutter/const/conts.dart';
import
'dart:convert'
;
import
'package:http/http.dart'
as
http
;
import
'package:medapp_eksad/api/contact_api.dart'
;
import
'package:medapp_eksad/widget/button_color.dart'
;
...
...
@@ -232,10 +233,10 @@ class _ContactUs2_smallState extends State<ContactUs2_small> {
style:
Btn_Submit
(),
onPressed:
()
async
{
if
(
_formKey
.
currentState
!.
validate
())
{
final
response
=
await
SendEmail
(
final
response
=
await
savecontact
(
nameController
.
value
.
text
,
phoneController
.
value
.
text
,
emailController
.
value
.
text
,
phoneController
.
value
.
text
,
messageController
.
value
.
text
);
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
response
==
200
...
...
@@ -267,30 +268,6 @@ class _ContactUs2_smallState extends State<ContactUs2_small> {
),
);
}
Future
SendEmail
(
String
name
,
String
phone
,
String
email
,
String
message
)
async
{
final
url
=
Uri
.
parse
(
'https://api.emailjs.com/api/v1.0/email/send'
);
const
serviceId
=
'service_wava70j'
;
const
templateId
=
'template_koc73cj'
;
const
userId
=
'h4BmDnyWlm3OziBDx'
;
final
response
=
await
http
.
post
(
url
,
headers:
{
'Content-Type'
:
'application/json'
},
//This line makes sure it works for all platforms.
body:
json
.
encode
({
'service_id'
:
serviceId
,
'template_id'
:
templateId
,
'user_id'
:
userId
,
'template_params'
:
{
'from_name'
:
name
,
'from_phone'
:
phone
,
'to_email'
:
email
,
'message'
:
message
}
}));
return
response
.
statusCode
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment