Fakultas Ilmu Komputer UI

Commit d6835500 authored by Ferdi Salim Sungkar's avatar Ferdi Salim Sungkar
Browse files

[GREEN] adding if-else into navigator

parent ec2c522a
Pipeline #78450 passed with stages
in 7 minutes and 42 seconds
......@@ -668,7 +668,7 @@
"languageVersion": "2.7"
}
],
"generated": "2021-05-21T14:49:47.659943Z",
"generated": "2021-05-23T11:57:26.997448Z",
"generator": "pub",
"generatorVersion": "2.12.0"
}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_keyboard_visibility","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-5.0.0/","dependencies":[]},{"name":"flutter_secure_storage","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.5/","dependencies":[]},{"name":"image_picker","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.7.4/","dependencies":[]},{"name":"path_provider","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.1/","dependencies":[]}],"android":[{"name":"flutter_keyboard_visibility","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-5.0.0/","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_plugin_android_lifecycle-2.0.1/","dependencies":[]},{"name":"flutter_secure_storage","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.5/","dependencies":[]},{"name":"image_picker","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.7.4/","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"path_provider","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.1/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.0/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.0.0/","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.0.0/","dependencies":[]}],"web":[{"name":"flutter_keyboard_visibility_web","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility_web-2.0.0/","dependencies":[]},{"name":"image_picker_for_web","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker_for_web-2.0.0/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_keyboard_visibility","dependencies":["flutter_keyboard_visibility_web"]},{"name":"flutter_keyboard_visibility_web","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"flutter_secure_storage","dependencies":[]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle","image_picker_for_web"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2021-05-21 21:49:47.804156","version":"2.0.1"}
\ No newline at end of file
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_keyboard_visibility","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-5.0.0/","dependencies":[]},{"name":"flutter_secure_storage","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.5/","dependencies":[]},{"name":"image_picker","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.7.4/","dependencies":[]},{"name":"path_provider","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.1/","dependencies":[]}],"android":[{"name":"flutter_keyboard_visibility","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-5.0.0/","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_plugin_android_lifecycle-2.0.1/","dependencies":[]},{"name":"flutter_secure_storage","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.5/","dependencies":[]},{"name":"image_picker","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.7.4/","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"path_provider","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.1/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.0/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.0.0/","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.0.0/","dependencies":[]}],"web":[{"name":"flutter_keyboard_visibility_web","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility_web-2.0.0/","dependencies":[]},{"name":"image_picker_for_web","path":"/Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker_for_web-2.0.0/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_keyboard_visibility","dependencies":["flutter_keyboard_visibility_web"]},{"name":"flutter_keyboard_visibility_web","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"flutter_secure_storage","dependencies":[]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle","image_picker_for_web"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2021-05-23 20:29:27.259904","version":"2.0.1"}
\ No newline at end of file
......@@ -3,7 +3,7 @@
#
# For more info see: https://dart.dev/go/dot-packages-deprecation
#
# Generated by pub on 2021-05-21 21:49:47.634473.
# Generated by pub on 2021-05-23 18:57:26.922118.
_fe_analyzer_shared:file:///Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-14.0.0/lib/
analyzer:file:///Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.41.2/lib/
args:file:///Users/ferdisungkar/flutter/.pub-cache/hosted/pub.dartlang.org/args-2.0.0/lib/
......
// This is a generated file; do not edit or check into version control.
FLUTTER_ROOT=/Users/ferdisungkar/flutter
FLUTTER_APPLICATION_PATH=/Users/ferdisungkar/Desktop/Files/Universitas-Indonesia/Semester-6/PPL/Project/ppl2021-d-slhape
FLUTTER_TARGET=lib/main.dart
FLUTTER_TARGET=/Users/ferdisungkar/Desktop/Files/Universitas-Indonesia/Semester-6/PPL/Project/ppl2021-d-slhape/lib/main.dart
FLUTTER_BUILD_DIR=build
SYMROOT=${SOURCE_ROOT}/../build/ios
FLUTTER_BUILD_NAME=1.0.0
FLUTTER_BUILD_NUMBER=1
DART_DEFINES=flutter.inspector.structuredErrors%3Dtrue
DART_OBFUSCATION=false
TRACK_WIDGET_CREATION=false
TRACK_WIDGET_CREATION=true
TREE_SHAKE_ICONS=false
PACKAGE_CONFIG=.packages
PACKAGE_CONFIG=/Users/ferdisungkar/Desktop/Files/Universitas-Indonesia/Semester-6/PPL/Project/ppl2021-d-slhape/.dart_tool/package_config.json
......@@ -2,12 +2,13 @@
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/ferdisungkar/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/ferdisungkar/Desktop/Files/Universitas-Indonesia/Semester-6/PPL/Project/ppl2021-d-slhape"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_TARGET=/Users/ferdisungkar/Desktop/Files/Universitas-Indonesia/Semester-6/PPL/Project/ppl2021-d-slhape/lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_DEFINES=flutter.inspector.structuredErrors%3Dtrue"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=false"
export "TRACK_WIDGET_CREATION=true"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.packages"
export "PACKAGE_CONFIG=/Users/ferdisungkar/Desktop/Files/Universitas-Indonesia/Semester-6/PPL/Project/ppl2021-d-slhape/.dart_tool/package_config.json"
......@@ -99,19 +99,15 @@ class Api {
}
Future patchMember(String name, int addressId, String phone) async {
var apiURL = Uri.parse(
'https://canary.fundex.id/api/v1.1/member');
var apiURL = Uri.parse('https://canary.fundex.id/api/v1.1/member');
var token = await secureStorage.readSecureData('accessToken');
final apiResult = await client.patch(apiURL,
headers: <String, String>{
'Content-type': 'application/json',
HttpHeaders.authorizationHeader: 'Bearer $token',
},
body: jsonEncode({
'name': name,
'address_id': addressId,
'phone': phone
}));
headers: <String, String>{
'Content-type': 'application/json',
HttpHeaders.authorizationHeader: 'Bearer $token',
},
body: jsonEncode(
{'name': name, 'address_id': addressId, 'phone': phone}));
if (apiResult.statusCode == 200) {
print('Patch member berhasil');
print(apiResult.statusCode);
......@@ -127,18 +123,15 @@ class Api {
}
Future<String> gender(String gen) async {
var apiURL = Uri.parse(
'https://canary.fundex.id/api/v1.1/member-attribute');
var apiURL =
Uri.parse('https://canary.fundex.id/api/v1.1/member-attribute');
var token = await secureStorage.readSecureData('accessToken');
final apiResult = await client.post(apiURL,
headers: <String, String>{
'Content-type': 'application/json',
HttpHeaders.authorizationHeader: 'Bearer $token',
},
body: jsonEncode({
'attribute_name': 'gender',
'attribute_value': gen
}));
headers: <String, String>{
'Content-type': 'application/json',
HttpHeaders.authorizationHeader: 'Bearer $token',
},
body: jsonEncode({'attribute_name': 'gender', 'attribute_value': gen}));
if (apiResult.statusCode == 200) {
print('gender berhasil');
print(apiResult.statusCode);
......@@ -146,7 +139,8 @@ class Api {
var jsonObject = json.decode(apiResult.body);
var jsonData = (jsonObject as Map<String, dynamic>)['data'];
var idMemberAttributeGender = jsonData['id'];
await secureStorage.writeSecureData('idMemberAttributeGender', idMemberAttributeGender);
await secureStorage.writeSecureData(
'idMemberAttributeGender', idMemberAttributeGender);
print(await secureStorage.readSecureData('idMemberAttributeGender'));
return 'Simpan Berhasil!';
} else {
......@@ -159,18 +153,16 @@ class Api {
}
Future birthdate(DateTime date) async {
var apiURL = Uri.parse(
'https://canary.fundex.id/api/v1.1/member-attribute');
var apiURL =
Uri.parse('https://canary.fundex.id/api/v1.1/member-attribute');
var token = await secureStorage.readSecureData('accessToken');
final apiResult = await client.post(apiURL,
headers: <String, String>{
'Content-type': 'application/json',
HttpHeaders.authorizationHeader: 'Bearer $token',
},
body: jsonEncode({
'attribute_name': 'birthdate',
'attribute_value': date
}));
headers: <String, String>{
'Content-type': 'application/json',
HttpHeaders.authorizationHeader: 'Bearer $token',
},
body: jsonEncode(
{'attribute_name': 'birthdate', 'attribute_value': date}));
if (apiResult.statusCode == 200) {
print('birthdate berhasil');
print(apiResult.statusCode);
......@@ -178,7 +170,8 @@ class Api {
var jsonObject = json.decode(apiResult.body);
var jsonData = (jsonObject as Map<String, dynamic>)['data'];
var idMemberAttributeBirthdate = jsonData['id'];
await secureStorage.writeSecureData('idMemberAttributeBirthdate', idMemberAttributeBirthdate);
await secureStorage.writeSecureData(
'idMemberAttributeBirthdate', idMemberAttributeBirthdate);
print(await secureStorage.readSecureData('idMemberAttributeBirthdate'));
return 'Simpan Berhasil!';
} else {
......@@ -191,18 +184,16 @@ class Api {
}
Future birthplace(String nameCity) async {
var apiURL = Uri.parse(
'https://canary.fundex.id/api/v1.1/member-attribute');
var apiURL =
Uri.parse('https://canary.fundex.id/api/v1.1/member-attribute');
var token = await secureStorage.readSecureData('accessToken');
final apiResult = await client.post(apiURL,
headers: <String, String>{
'Content-type': 'application/json',
HttpHeaders.authorizationHeader: 'Bearer $token',
},
body: jsonEncode({
'attribute_name': 'birthplace',
'attribute_value': nameCity
}));
headers: <String, String>{
'Content-type': 'application/json',
HttpHeaders.authorizationHeader: 'Bearer $token',
},
body: jsonEncode(
{'attribute_name': 'birthplace', 'attribute_value': nameCity}));
if (apiResult.statusCode == 200) {
print('birthplace berhasil');
print(apiResult.statusCode);
......@@ -210,7 +201,8 @@ class Api {
var jsonObject = json.decode(apiResult.body);
var jsonData = (jsonObject as Map<String, dynamic>)['data'];
var idMemberAttributeBirthplace = jsonData['id'];
await secureStorage.writeSecureData('idMemberAttributeBirthplace', idMemberAttributeBirthplace);
await secureStorage.writeSecureData(
'idMemberAttributeBirthplace', idMemberAttributeBirthplace);
print(await secureStorage.readSecureData('idMemberAttributeBirthplace'));
return 'Simpan Berhasil!';
} else {
......@@ -245,7 +237,8 @@ class Api {
}
Future getRefCity() async {
final apiURL = Uri.parse('https://canary.fundex.id/api/v1.1/ref-cities?offset=&limit=');
final apiURL = Uri.parse(
'https://canary.fundex.id/api/v1.1/ref-cities?offset=&limit=');
var token = await secureStorage.readSecureData('accessToken');
var headers = {
'Content-type': 'application/json',
......@@ -271,7 +264,8 @@ class Api {
}
Future getRefState() async {
final apiURL = Uri.parse('https://canary.fundex.id/api/v1.1/ref-states?offset=&limit=');
final apiURL = Uri.parse(
'https://canary.fundex.id/api/v1.1/ref-states?offset=&limit=');
var token = await secureStorage.readSecureData('accessToken');
var headers = {
'Content-type': 'application/json',
......@@ -297,7 +291,8 @@ class Api {
}
Future getRefDistrict() async {
final apiURL = Uri.parse('https://canary.fundex.id/api/v1.1/ref-districts?offset=&limit=');
final apiURL = Uri.parse(
'https://canary.fundex.id/api/v1.1/ref-districts?offset=&limit=');
var token = await secureStorage.readSecureData('accessToken');
var headers = {
'Content-type': 'application/json',
......@@ -322,28 +317,22 @@ class Api {
}
}
Future postAddress(
String address,
String district,
String city,
String province,
String zipCode
) async {
var apiURL = Uri.parse(
'https://canary.fundex.id/api/v1.1/address');
Future postAddress(String address, String district, String city,
String province, String zipCode) async {
var apiURL = Uri.parse('https://canary.fundex.id/api/v1.1/address');
var token = await secureStorage.readSecureData('accessToken');
final apiResult = await client.post(apiURL,
headers: <String, String>{
HttpHeaders.authorizationHeader: 'Bearer $token',
},
body: jsonEncode(<String, String>{
"address": address,
"district": district,
"city": city,
"province": province,
"country": "Indonesia",
"zip_code": zipCode
}));
headers: <String, String>{
HttpHeaders.authorizationHeader: 'Bearer $token',
},
body: jsonEncode(<String, String>{
"address": address,
"district": district,
"city": city,
"province": province,
"country": "Indonesia",
"zip_code": zipCode
}));
if (apiResult.statusCode == 200) {
// var jsonObject = json.decode(apiResult.body);
// var data = (jsonObject as Map<String, dynamic>)['data'];
......@@ -363,4 +352,14 @@ class Api {
throw Exception('Gagal menyimpan..');
}
}
Future forgetPassword(String email, int statusCode) async {
final apiURL =
Uri.parse('https://canary.fundex.id/api/v1.1/auth/forgot-password');
var body = jsonEncode({'email': email});
var headers = {'Content-type': 'application/json'};
var apiResult = await client.post(apiURL, headers: headers, body: body);
statusCode = apiResult.statusCode;
return (statusCode);
}
}
import 'package:flutter/material.dart';
import 'package:fundex_app/api/api.dart';
import 'package:fundex_app/assets/colors.dart';
import 'package:fundex_app/pages/forget-password/EmailSent.dart';
import 'package:google_fonts/google_fonts.dart';
......@@ -22,6 +23,7 @@ class ForgetPassword extends StatefulWidget {
class _ForgetPasswordState extends State<ForgetPassword> {
final _keyForm = GlobalKey<FormState>();
var statusCode = 0;
InputDecoration formInputDecoration() {
return InputDecoration(
......@@ -133,17 +135,24 @@ class _ForgetPasswordState extends State<ForgetPassword> {
height: 52,
child: ElevatedButton(
key: Key('sendButton'),
onPressed: () {
onPressed: () async {
if (!_keyForm.currentState.validate()) {
return;
}
_keyForm.currentState.save();
print(email);
Navigator.push(context,
MaterialPageRoute(builder: (context) {
return MaterialApp(home: EmailSent());
}));
statusCode =
await Api().forgetPassword(email, statusCode);
print(statusCode);
print(statusCode);
if (statusCode == 200) {
Navigator.push(context,
MaterialPageRoute(builder: (context) {
return MaterialApp(home: EmailSent());
}));
print('masuk');
}
},
child: Text(
'Kirim',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment