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
30a7d9c2
Commit
30a7d9c2
authored
Sep 20, 2022
by
Budi Prasetyo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
register with firebase
parent
523fc0a2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
839 additions
and
309 deletions
+839
-309
user_api.dart
lib/api/user_api.dart
+9
-6
firebase_auth_methods.dart
lib/firebase/firebase_auth_methods.dart
+250
-0
showOtpDialog.dart
lib/firebase/showOtpDialog.dart
+29
-0
showSnackbar.dart
lib/firebase/showSnackbar.dart
+9
-0
main.dart
lib/main.dart
+38
-17
register.dart
lib/register.dart
+504
-286
No files found.
lib/api/user_api.dart
View file @
30a7d9c2
...
@@ -6,15 +6,18 @@ import 'package:medapp_eksad/model/user_model.dart';
...
@@ -6,15 +6,18 @@ import 'package:medapp_eksad/model/user_model.dart';
var
cmd
=
'https://dmsdev-api.eksad.com/gateway/medapp/v1/cmd'
;
var
cmd
=
'https://dmsdev-api.eksad.com/gateway/medapp/v1/cmd'
;
var
qry
=
'https://dmsdev-api.eksad.com/gateway/medapp/v1/qry'
;
var
qry
=
'https://dmsdev-api.eksad.com/gateway/medapp/v1/qry'
;
Future
<
bool
>
signUp
(
nama
,
email
,
nohp
,
username
,
password
)
async
{
Future
<
bool
>
signUp
(
nama
rs
,
nors
,
alamatrs
,
namapic
,
nopic
,
email
,
password
)
async
{
final
response
=
await
http
.
post
(
final
response
=
await
http
.
post
(
Uri
.
parse
(
'
$cmd
/user/signup'
),
Uri
.
parse
(
'
$cmd
/user/signup'
),
body:
jsonEncode
({
body:
jsonEncode
({
"namaUser"
:
nama
,
"namaRs"
:
namars
,
"emailUser"
:
email
,
"noRs"
:
nors
,
"noHp"
:
nohp
,
"alamatRs"
:
alamatrs
,
"username"
:
username
,
"namaPic"
:
namapic
,
"password"
:
password
}),
"noPic"
:
nopic
,
"emailPic"
:
email
,
"password"
:
password
}),
headers:
{
headers:
{
'Content-type'
:
'application/json; charset=UTF-8'
,
'Content-type'
:
'application/json; charset=UTF-8'
,
}
}
...
...
lib/firebase/firebase_auth_methods.dart
0 → 100644
View file @
30a7d9c2
import
'package:firebase_auth/firebase_auth.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:medapp_eksad/firebase/showOtpDialog.dart'
;
import
'package:medapp_eksad/firebase/showSnackbar.dart'
;
class
FirebaseAuthMethods
{
final
FirebaseAuth
_auth
;
FirebaseAuthMethods
(
this
.
_auth
);
// FOR EVERY FUNCTION HERE
// POP THE ROUTE USING: Navigator.of(context).pushNamedAndRemoveUntil('/', (Route<dynamic> route) => false);
// GET USER DATA
// using null check operator since this method should be called only
// when the user is logged in
User
get
user
=>
_auth
.
currentUser
!;
// STATE PERSISTENCE STREAM
Stream
<
User
?>
get
authState
=>
FirebaseAuth
.
instance
.
authStateChanges
();
// OTHER WAYS (depends on use case):
// Stream get authState => FirebaseAuth.instance.userChanges();
// Stream get authState => FirebaseAuth.instance.idTokenChanges();
// KNOW MORE ABOUT THEM HERE: https://firebase.flutter.dev/docs/auth/start#auth-state
// EMAIL SIGN UP
Future
<
void
>
signUpWithEmail
({
required
String
nameRS
,
required
String
phoneRS
,
required
String
addressRS
,
required
String
namePIC
,
required
String
phonePIC
,
required
String
addressPIC
,
required
String
email
,
required
String
password
,
required
BuildContext
context
,
})
async
{
try
{
await
_auth
.
createUserWithEmailAndPassword
(
// nameRS: nameRS,
// phoneRS: phoneRS,
// addressRS: addressRS,
// namePIC: namePIC,
// phonePIC: phonePIC,
// addressPIC: addressPIC,
email:
email
,
password:
password
,
);
await
sendEmailVerification
(
context
);
}
on
FirebaseAuthException
catch
(
e
)
{
// if you want to display your own custom error message
if
(
e
.
code
==
'weak-password'
)
{
print
(
'The password provided is too weak.'
);
}
else
if
(
e
.
code
==
'email-already-in-use'
)
{
print
(
'The account already exists for that email.'
);
}
showSnackBar
(
context
,
e
.
message
!);
// Displaying the usual firebase error message
}
}
// EMAIL LOGIN
Future
<
void
>
loginWithEmail
({
// required String nameRS,
// required String phoneRS,
// required String addressRS,
// required String namePIC,
// required String phonePIC,
// required String addressPIC,
required
String
email
,
required
String
password
,
required
BuildContext
context
,
})
async
{
try
{
await
_auth
.
signInWithEmailAndPassword
(
// nameRS: nameRS,
// phoneRS: phoneRS,
// addressRS: addressRS,
// namePIC: namePIC,
// phonePIC: phonePIC,
// addressPIC: addressPIC,
email:
email
,
password:
password
,
);
if
(!
user
.
emailVerified
)
{
await
sendEmailVerification
(
context
);
// restrict access to certain things using provider
// transition to another page instead of home screen
}
}
on
FirebaseAuthException
catch
(
e
)
{
showSnackBar
(
context
,
e
.
message
!);
// Displaying the error message
}
}
// EMAIL VERIFICATION
Future
<
void
>
sendEmailVerification
(
BuildContext
context
)
async
{
try
{
_auth
.
currentUser
!.
sendEmailVerification
();
showSnackBar
(
context
,
'Email verification sent!'
);
}
on
FirebaseAuthException
catch
(
e
)
{
showSnackBar
(
context
,
e
.
message
!);
// Display error message
}
}
// GOOGLE SIGN IN
// Future<void> signInWithGoogle(BuildContext context) async {
// try {
// if (kIsWeb) {
// GoogleAuthProvider googleProvider = GoogleAuthProvider();
//
// googleProvider
// .addScope('https://www.googleapis.com/auth/contacts.readonly');
//
// await _auth.signInWithPopup(googleProvider);
// } else {
// final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();
//
// final GoogleSignInAuthentication? googleAuth =
// await googleUser?.authentication;
//
// if (googleAuth?.accessToken != null && googleAuth?.idToken != null) {
// // Create a new credential
// final credential = GoogleAuthProvider.credential(
// accessToken: googleAuth?.accessToken,
// idToken: googleAuth?.idToken,
// );
// UserCredential userCredential =
// await _auth.signInWithCredential(credential);
//
// // if you want to do specific task like storing information in firestore
// // only for new users using google sign in (since there are no two options
// // for google sign in and google sign up, only one as of now),
// // do the following:
//
// // if (userCredential.user != null) {
// // if (userCredential.additionalUserInfo!.isNewUser) {}
// // }
// }
// }
// } on FirebaseAuthException catch (e) {
// showSnackBar(context, e.message!); // Displaying the error message
// }
// }
// ANONYMOUS SIGN IN
Future
<
void
>
signInAnonymously
(
BuildContext
context
)
async
{
try
{
await
_auth
.
signInAnonymously
();
}
on
FirebaseAuthException
catch
(
e
)
{
showSnackBar
(
context
,
e
.
message
!);
// Displaying the error message
}
}
// FACEBOOK SIGN IN
// Future<void> signInWithFacebook(BuildContext context) async {
// try {
// final LoginResult loginResult = await FacebookAuth.instance.login();
//
// final OAuthCredential facebookAuthCredential =
// FacebookAuthProvider.credential(loginResult.accessToken!.token);
//
// await _auth.signInWithCredential(facebookAuthCredential);
// } on FirebaseAuthException catch (e) {
// showSnackBar(context, e.message!); // Displaying the error message
// }
// }
// PHONE SIGN IN
Future
<
void
>
phoneSignIn
(
BuildContext
context
,
String
phoneNumber
,
)
async
{
TextEditingController
codeController
=
TextEditingController
();
if
(
kIsWeb
)
{
// !!! Works only on web !!!
ConfirmationResult
result
=
await
_auth
.
signInWithPhoneNumber
(
phoneNumber
);
// Diplay Dialog Box To accept OTP
showOTPDialog
(
codeController:
codeController
,
context:
context
,
onPressed:
()
async
{
PhoneAuthCredential
credential
=
PhoneAuthProvider
.
credential
(
verificationId:
result
.
verificationId
,
smsCode:
codeController
.
text
.
trim
(),
);
await
_auth
.
signInWithCredential
(
credential
);
Navigator
.
of
(
context
).
pop
();
// Remove the dialog box
},
);
}
else
{
// FOR ANDROID, IOS
await
_auth
.
verifyPhoneNumber
(
phoneNumber:
phoneNumber
,
// Automatic handling of the SMS code
verificationCompleted:
(
PhoneAuthCredential
credential
)
async
{
// !!! works only on android !!!
await
_auth
.
signInWithCredential
(
credential
);
},
// Displays a message when verification fails
verificationFailed:
(
e
)
{
showSnackBar
(
context
,
e
.
message
!);
},
// Displays a dialog box when OTP is sent
codeSent:
((
String
verificationId
,
int
?
resendToken
)
async
{
showOTPDialog
(
codeController:
codeController
,
context:
context
,
onPressed:
()
async
{
PhoneAuthCredential
credential
=
PhoneAuthProvider
.
credential
(
verificationId:
verificationId
,
smsCode:
codeController
.
text
.
trim
(),
);
// !!! Works only on Android, iOS !!!
await
_auth
.
signInWithCredential
(
credential
);
Navigator
.
of
(
context
).
pop
();
// Remove the dialog box
},
);
}),
codeAutoRetrievalTimeout:
(
String
verificationId
)
{
// Auto-resolution timed out...
},
);
}
}
// SIGN OUT
Future
<
void
>
signOut
(
BuildContext
context
)
async
{
try
{
await
_auth
.
signOut
();
}
on
FirebaseAuthException
catch
(
e
)
{
showSnackBar
(
context
,
e
.
message
!);
// Displaying the error message
}
}
// DELETE ACCOUNT
Future
<
void
>
deleteAccount
(
BuildContext
context
)
async
{
try
{
await
_auth
.
currentUser
!.
delete
();
}
on
FirebaseAuthException
catch
(
e
)
{
showSnackBar
(
context
,
e
.
message
!);
// Displaying the error message
// if an error of requires-recent-login is thrown, make sure to log
// in user again and then delete account.
}
}
}
lib/firebase/showOtpDialog.dart
0 → 100644
View file @
30a7d9c2
import
'package:flutter/material.dart'
;
void
showOTPDialog
(
{
required
BuildContext
context
,
required
TextEditingController
codeController
,
required
VoidCallback
onPressed
,
})
{
showDialog
(
context:
context
,
barrierDismissible:
false
,
builder:
(
context
)
=>
AlertDialog
(
title:
const
Text
(
"Enter OTP"
),
content:
Column
(
mainAxisSize:
MainAxisSize
.
min
,
children:
<
Widget
>[
TextField
(
controller:
codeController
,
),
],
),
actions:
<
Widget
>[
TextButton
(
child:
const
Text
(
"Done"
),
onPressed:
onPressed
,
)
],
),
);
}
lib/firebase/showSnackbar.dart
0 → 100644
View file @
30a7d9c2
import
'package:flutter/material.dart'
;
void
showSnackBar
(
BuildContext
context
,
String
text
)
{
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
text
),
),
);
}
lib/main.dart
View file @
30a7d9c2
import
'package:firebase_auth/firebase_auth.dart'
;
import
'package:firebase_core/firebase_core.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:medapp_eksad/auth/forget_password.dart'
;
import
'package:medapp_eksad/auth/forget_password.dart'
;
import
'package:medapp_eksad/dashboard/admin/main_dashboard_admin.dart'
;
import
'package:medapp_eksad/dashboard/admin/main_dashboard_admin.dart'
;
import
'package:medapp_eksad/firebase/firebase_auth_methods.dart'
;
import
'package:medapp_eksad/firebase_options.dart'
;
import
'package:medapp_eksad/homepage.dart'
;
import
'package:medapp_eksad/homepage.dart'
;
import
'package:medapp_eksad/login.dart'
;
import
'package:medapp_eksad/login.dart'
;
import
'package:medapp_eksad/register.dart'
;
import
'package:medapp_eksad/register.dart'
;
...
@@ -8,8 +12,13 @@ import 'package:medapp_eksad/register_pic.dart';
...
@@ -8,8 +12,13 @@ import 'package:medapp_eksad/register_pic.dart';
import
'package:medapp_eksad/screen/contact_us/contact_us.dart'
;
import
'package:medapp_eksad/screen/contact_us/contact_us.dart'
;
import
'package:medapp_eksad/screen/solution.dart'
;
import
'package:medapp_eksad/screen/solution.dart'
;
import
'package:medapp_eksad/screen_user/demo_user.dart'
;
import
'package:medapp_eksad/screen_user/demo_user.dart'
;
import
'package:provider/provider.dart'
;
void
main
(
)
{
void
main
(
)
async
{
WidgetsFlutterBinding
.
ensureInitialized
();
await
Firebase
.
initializeApp
(
options:
DefaultFirebaseOptions
.
currentPlatform
,
);
runApp
(
const
MyApp
());
runApp
(
const
MyApp
());
}
}
...
@@ -18,22 +27,34 @@ class MyApp extends StatelessWidget {
...
@@ -18,22 +27,34 @@ class MyApp extends StatelessWidget {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
return
MultiProvider
(
debugShowCheckedModeBanner:
false
,
providers:
[
title:
"MedApp by Eksad"
,
Provider
<
FirebaseAuthMethods
>(
initialRoute:
'/'
,
create:
(
_
)
=>
FirebaseAuthMethods
(
FirebaseAuth
.
instance
),
routes:
{
),
'/'
:
(
context
)
=>
const
HomePage
(),
StreamProvider
(
'/about'
:
(
context
)
=>
const
HomePage
(),
create:
(
context
)
=>
context
.
read
<
FirebaseAuthMethods
>().
authState
,
'/solutions'
:
(
context
)
=>
const
Solutions
(),
initialData:
null
,
'/contact'
:
(
context
)
=>
const
ContactUs
(),
),
'/login'
:
(
context
)
=>
const
SignIn
(),
],
'/register'
:
(
context
)
=>
const
RegisterPic
(),
child:
MaterialApp
(
'/dashboard'
:
(
context
)
=>
const
DashboardAdmin
(),
debugShowCheckedModeBanner:
false
,
'/reset_password'
:
(
context
)
=>
const
ForgotPassword
(),
title:
"MedApp by Eksad"
,
'/demo'
:
(
context
)
=>
const
DemoUser
(),
initialRoute:
'/'
,
//'/register_pic': (context) => const RegisterPic(),
routes:
{
},
'/'
:
(
context
)
=>
const
HomePage
(),
'/about'
:
(
context
)
=>
const
HomePage
(),
'/solutions'
:
(
context
)
=>
const
Solutions
(),
'/contact'
:
(
context
)
=>
const
ContactUs
(),
'/login'
:
(
context
)
=>
const
SignIn
(),
//'/register': (context) => const RegisterPic(),
'/register'
:
(
context
)
=>
const
Register
(),
'/dashboard'
:
(
context
)
=>
const
DashboardAdmin
(),
'/reset_password'
:
(
context
)
=>
const
ForgotPassword
(),
'/demo'
:
(
context
)
=>
const
DemoUser
(),
//'/register_pic': (context) => const RegisterPic(),
},
),
);
);
}
}
}
}
lib/register.dart
View file @
30a7d9c2
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:medapp_eksad/api/user_api.dart'
;
import
'package:medapp_eksad/api/user_api.dart'
;
import
'package:medapp_eksad/firebase/firebase_auth_methods.dart'
;
import
'package:provider/provider.dart'
;
class
Register
extends
StatefulWidget
{
class
Register
extends
StatefulWidget
{
//static String routeName = '/register';
const
Register
({
Key
?
key
})
:
super
(
key:
key
);
const
Register
({
Key
?
key
})
:
super
(
key:
key
);
@override
@override
...
@@ -9,16 +13,39 @@ class Register extends StatefulWidget {
...
@@ -9,16 +13,39 @@ class Register extends StatefulWidget {
}
}
class
_RegisterState
extends
State
<
Register
>
{
class
_RegisterState
extends
State
<
Register
>
{
bool
_isObscure
=
true
;
bool
_isObscure
=
true
;
final
_formKey
=
GlobalKey
<
FormState
>();
final
_formKey
=
GlobalKey
<
FormState
>();
final
nameController
=
TextEditingController
();
final
nameRSController
=
TextEditingController
();
final
emailController
=
TextEditingController
();
final
phoneRSController
=
TextEditingController
();
final
phoneController
=
TextEditingController
();
final
addressRSController
=
TextEditingController
();
final
usernameController
=
TextEditingController
();
final
namePICController
=
TextEditingController
();
final
pwController
=
TextEditingController
();
final
phonePICController
=
TextEditingController
();
final
addressPICController
=
TextEditingController
();
final
emailPICController
=
TextEditingController
();
final
passwordController
=
TextEditingController
();
void
signUpUser
()
async
{
context
.
read
<
FirebaseAuthMethods
>().
signUpWithEmail
(
nameRS:
nameRSController
.
text
,
phoneRS:
phoneRSController
.
text
,
addressRS:
addressRSController
.
text
,
namePIC:
namePICController
.
text
,
phonePIC:
phonePICController
.
text
,
addressPIC:
addressPICController
.
text
,
email:
emailPICController
.
text
,
password:
passwordController
.
text
,
context:
context
,
);
signUp
(
nameRSController
.
value
.
text
,
phoneRSController
.
value
.
text
,
addressRSController
.
value
.
text
,
namePICController
.
value
.
text
,
phonePICController
.
value
.
text
,
emailPICController
.
value
.
text
,
passwordController
.
value
.
text
);
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
...
@@ -27,21 +54,19 @@ class _RegisterState extends State<Register> {
...
@@ -27,21 +54,19 @@ class _RegisterState extends State<Register> {
body:
Container
(
body:
Container
(
height:
screenize
.
height
,
height:
screenize
.
height
,
width:
screenize
.
width
,
width:
screenize
.
width
,
decoration:
const
BoxDecoration
(
decoration:
const
BoxDecoration
(
image:
DecorationImage
(
image:
DecorationImage
(
image:
AssetImage
(
"assets/images/bg-medapp.png"
),
image:
AssetImage
(
"assets/images/bg-medapp.png"
),
fit:
BoxFit
.
fill
,
fit:
BoxFit
.
fill
,
)
)),
),
padding:
EdgeInsets
.
only
(
padding:
EdgeInsets
.
only
(
left:
screenize
.
width
*
0.13
,
left:
screenize
.
width
*
0.13
,
top:
screenize
.
height
*
0.05
,
top:
screenize
.
height
*
0.05
,
bottom:
screenize
.
height
*
0.05
bottom:
screenize
.
height
*
0.05
),
),
child:
Stack
(
child:
Stack
(
children:
[
children:
[
Padding
(
Padding
(
padding:
EdgeInsets
.
symmetric
(
vertical:
screenize
.
height
*
0.15
),
padding:
EdgeInsets
.
symmetric
(
vertical:
screenize
.
height
*
0.15
),
// child: Container(
// child: Container(
// decoration: BoxDecoration(
// decoration: BoxDecoration(
// color: const Color.fromARGB(255, 10, 116, 255),
// color: const Color.fromARGB(255, 10, 116, 255),
...
@@ -54,15 +79,15 @@ class _RegisterState extends State<Register> {
...
@@ -54,15 +79,15 @@ class _RegisterState extends State<Register> {
// ),
// ),
// ),
// ),
child:
Image
.
asset
(
child:
Image
.
asset
(
"assets/logo/logo-eksad.png"
,
"assets/logo/logo-eksad.png"
,
),
),
),
),
Padding
(
Padding
(
padding:
EdgeInsets
.
only
(
padding:
EdgeInsets
.
only
(
left:
screenize
.
width
*
0.35
,
left:
screenize
.
width
*
0.35
,
),
),
child:
Container
(
child:
Container
(
width:
screenize
.
width
*
0.
3
0
,
width:
screenize
.
width
*
0.
5
0
,
height:
screenize
.
height
*
1
,
height:
screenize
.
height
*
1
,
alignment:
Alignment
.
center
,
alignment:
Alignment
.
center
,
decoration:
BoxDecoration
(
decoration:
BoxDecoration
(
...
@@ -74,23 +99,24 @@ class _RegisterState extends State<Register> {
...
@@ -74,23 +99,24 @@ class _RegisterState extends State<Register> {
),
),
boxShadow:
[
boxShadow:
[
BoxShadow
(
BoxShadow
(
color:
const
Color
.
fromARGB
(
255
,
10
,
116
,
255
).
withAlpha
(
60
),
color:
const
Color
.
fromARGB
(
255
,
10
,
116
,
255
).
withAlpha
(
60
),
blurRadius:
15.0
,
blurRadius:
15.0
,
spreadRadius:
20.0
,
spreadRadius:
20.0
,
offset:
const
Offset
(
offset:
const
Offset
(
0.0
,
0.0
,
3.0
,
3.0
,
),
),
),],
),
],
),
),
child:
Form
(
child:
Form
(
key:
_formKey
,
key:
_formKey
,
child:
Container
(
child:
Container
(
padding:
EdgeInsets
.
only
(
padding:
EdgeInsets
.
only
(
left:
screenize
.
width
*
0.045
,
left:
screenize
.
width
*
0.045
,
top:
screenize
.
height
*
0.01
top:
screenize
.
height
*
0.01
),
),
width:
screenize
.
width
*
0.50
,
width:
screenize
.
width
*
0.36
,
height:
screenize
.
height
*
1
,
height:
screenize
.
height
*
1
,
child:
Column
(
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
...
@@ -98,312 +124,503 @@ class _RegisterState extends State<Register> {
...
@@ -98,312 +124,503 @@ class _RegisterState extends State<Register> {
children:
[
children:
[
const
Spacer
(),
const
Spacer
(),
Container
(
Container
(
padding:
EdgeInsets
.
only
(
padding:
left:
screenize
.
width
*
0.05
EdgeInsets
.
only
(
left:
screenize
.
width
*
0.15
),
),
height:
screenize
.
width
*
0.03
,
height:
screenize
.
width
*
0.03
,
child:
Image
.
asset
(
"assets/logo/medapp-logo.png"
),
//
child: Image.asset("assets/logo/medapp-logo.png"),
),
),
const
SizedBox
(
height:
20
,),
const
SizedBox
(
Row
(
height:
20
,
children:
[
Icon
(
Icons
.
drive_file_rename_outline
,
color:
Colors
.
grey
[
500
],
size:
screenize
.
width
*
0.01
,
),
const
SizedBox
(
width:
10
,
),
const
Text
(
"Nama"
,
style:
TextStyle
(
fontSize:
13
),
),
],
),
),
const
SizedBox
(
height:
5
,),
Row
(
Row
(
children:
[
children:
[
SizedBox
(
Column
(
height:
60
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
width:
screenize
.
width
*
0.2
,
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
child:
TextFormField
(
children:
[
controller:
nameController
,
// ===============nama rs=============
textAlign:
TextAlign
.
start
,
Row
(
decoration:
InputDecoration
(
children:
[
labelText:
"Nama Lengkap"
,
Icon
(
labelStyle:
TextStyle
(
Icons
.
drive_file_rename_outline
,
fontSize:
13
color:
Colors
.
grey
[
500
],
),
size:
screenize
.
width
*
0.01
,
border:
OutlineInputBorder
(
),
borderRadius:
BorderRadius
.
circular
(
5.0
),
const
SizedBox
(
)
width:
10
,
),
const
Text
(
"Nama Rumah Sakit"
,
style:
TextStyle
(
fontSize:
13
),
),
],
),
),
validator:
(
value
){
const
SizedBox
(
if
(
value
==
null
||
value
.
isEmpty
){
height:
5
,
return
"Nama tidak boleh kosong"
;
),
}
Row
(
return
null
;
children:
[
},
SizedBox
(
),
height:
60
,
)
width:
screenize
.
width
*
0.2
,
],
child:
TextFormField
(
),
controller:
nameRSController
,
textAlign:
TextAlign
.
start
,
const
SizedBox
(
height:
5
,),
decoration:
InputDecoration
(
Row
(
labelText:
"Nama Rumah Sakit"
,
children:
[
labelStyle:
TextStyle
(
fontSize:
13
),
Icon
(
border:
OutlineInputBorder
(
Icons
.
email_outlined
,
borderRadius:
color:
Colors
.
grey
[
500
],
BorderRadius
.
circular
(
5.0
),
size:
screenize
.
width
*
0.01
,
)),
validator:
(
value
)
{
if
(
value
==
null
||
value
.
isEmpty
)
{
return
"Nama Rumah Sakit tidak boleh kosong"
;
}
return
null
;
},
),
)
],
),
// ===============akhir nama rs=============
],
),
),
const
SizedBox
(
const
SizedBox
(
width:
1
0
,
width:
3
0
,
),
),
const
Text
(
"Email"
,
Column
(
style:
TextStyle
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
fontSize:
13
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
),
children:
[
// ===============telepon rs==========
Row
(
children:
[
Icon
(
Icons
.
phone_android
,
color:
Colors
.
grey
[
500
],
size:
screenize
.
width
*
0.01
,
),
const
SizedBox
(
width:
10
,
),
const
Text
(
"No Telepon Rumah Sakit"
,
style:
TextStyle
(
fontSize:
13
),
),
],
),
const
SizedBox
(
height:
5
,
),
Row
(
children:
[
SizedBox
(
height:
60
,
width:
screenize
.
width
*
0.2
,
child:
TextFormField
(
controller:
phoneRSController
,
textAlign:
TextAlign
.
start
,
validator:
(
value
)
{
if
(
value
==
null
||
value
.
isEmpty
)
{
return
"Nomor Telepon Rumah Sakit tidak boleh kosong"
;
}
return
null
;
},
decoration:
InputDecoration
(
labelText:
"Nomor Telepon Rumah Sakit"
,
labelStyle:
TextStyle
(
fontSize:
13
),
hintStyle:
const
TextStyle
(),
border:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
circular
(
5.0
),
)),
),
)
],
),
// ===============akhir telepon rs==========
],
),
),
],
],
),
),
const
SizedBox
(
height:
5
,),
Row
(
Row
(
children:
[
children:
[
SizedBox
(
Column
(
height:
60
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
width:
screenize
.
width
*
0.2
,
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
child:
TextFormField
(
children:
[
controller:
emailController
,
// ===============alamat rs==========
textAlign:
TextAlign
.
start
,
Row
(
validator:
(
value
){
children:
[
if
(
value
==
null
||
value
.
isEmpty
){
Icon
(
return
"Email tidak boleh kosong"
;
Icons
.
add_home_work_sharp
,
}
color:
Colors
.
grey
[
500
],
return
null
;
size:
screenize
.
width
*
0.01
,
},
),
decoration:
InputDecoration
(
const
SizedBox
(
labelText:
"Email Valid"
,
width:
10
,
labelStyle:
TextStyle
(
fontSize:
13
),
),
hintStyle:
const
TextStyle
(),
const
Text
(
border:
OutlineInputBorder
(
"Alamat Rumah Sakit"
,
borderRadius:
BorderRadius
.
circular
(
5.0
),
style:
TextStyle
(
fontSize:
13
),
),
],
),
const
SizedBox
(
height:
5
,
),
Row
(
children:
[
SizedBox
(
height:
60
,
width:
screenize
.
width
*
0.2
,
child:
TextFormField
(
controller:
addressRSController
,
textAlign:
TextAlign
.
start
,
validator:
(
value
)
{
if
(
value
==
null
||
value
.
isEmpty
)
{
return
"Nomor Alamat Rumah Sakit tidak boleh kosong"
;
}
return
null
;
},
decoration:
InputDecoration
(
labelText:
"Nomor Alamat Rumah Sakit"
,
labelStyle:
TextStyle
(
fontSize:
13
),
hintStyle:
const
TextStyle
(),
border:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
circular
(
5.0
),
)),
),
)
)
],
),
),
),
// ===============akhir alamat rs==========
)
],
],
),
const
SizedBox
(
height:
5
,),
Row
(
children:
[
Icon
(
Icons
.
phone_android
,
color:
Colors
.
grey
[
500
],
size:
screenize
.
width
*
0.01
,
),
),
const
SizedBox
(
const
SizedBox
(
width:
1
0
,
width:
3
0
,
),
),
const
Text
(
"No Hp"
,
Column
(
style:
TextStyle
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
fontSize:
13
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
),
children:
[
// ===============nama pic=============
Row
(
children:
[
Icon
(
Icons
.
drive_file_rename_outline
,
color:
Colors
.
grey
[
500
],
size:
screenize
.
width
*
0.01
,
),
const
SizedBox
(
width:
10
,
),
const
Text
(
"Nama PIC"
,
style:
TextStyle
(
fontSize:
13
),
),
],
),
const
SizedBox
(
height:
5
,
),
Row
(
children:
[
SizedBox
(
height:
60
,
width:
screenize
.
width
*
0.2
,
child:
TextFormField
(
controller:
namePICController
,
textAlign:
TextAlign
.
start
,
decoration:
InputDecoration
(
labelText:
"Nama PIC"
,
labelStyle:
TextStyle
(
fontSize:
13
),
border:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
circular
(
5.0
),
)),
validator:
(
value
)
{
if
(
value
==
null
||
value
.
isEmpty
)
{
return
"Nama PIC tidak boleh kosong"
;
}
return
null
;
},
),
)
],
),
// ===============akhir nama pic=============
],
),
),
],
],
),
),
const
SizedBox
(
height:
5
,),
Row
(
Row
(
children:
[
children:
[
SizedBox
(
Column
(
height:
60
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
width:
screenize
.
width
*
0.2
,
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
child:
TextFormField
(
children:
[
controller:
phoneController
,
// ===============telepon pic==========
textAlign:
TextAlign
.
start
,
Row
(
validator:
(
value
){
children:
[
if
(
value
==
null
||
value
.
isEmpty
){
Icon
(
return
"Nomor handphone tidak boleh kosong"
;
Icons
.
phone_android
,
}
color:
Colors
.
grey
[
500
],
return
null
;
size:
screenize
.
width
*
0.01
,
},
),
decoration:
InputDecoration
(
const
SizedBox
(
labelText:
"Nomor Handphone"
,
width:
10
,
labelStyle:
TextStyle
(
fontSize:
13
),
),
hintStyle:
const
TextStyle
(),
const
Text
(
border:
OutlineInputBorder
(
"No Telepon PIC"
,
borderRadius:
BorderRadius
.
circular
(
5.0
),
style:
TextStyle
(
fontSize:
13
),
),
],
),
const
SizedBox
(
height:
5
,
),
Row
(
children:
[
SizedBox
(
height:
60
,
width:
screenize
.
width
*
0.2
,
child:
TextFormField
(
controller:
phonePICController
,
textAlign:
TextAlign
.
start
,
validator:
(
value
)
{
if
(
value
==
null
||
value
.
isEmpty
)
{
return
"Nomor Telepon PIC tidak boleh kosong"
;
}
return
null
;
},
decoration:
InputDecoration
(
labelText:
"Nomor Telepon PIC"
,
labelStyle:
TextStyle
(
fontSize:
13
),
hintStyle:
const
TextStyle
(),
border:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
circular
(
5.0
),
)),
),
)
)
],
),
),
),
// ===============akhir telepon pic==========
)
],
],
),
const
SizedBox
(
height:
5
,),
Row
(
children:
[
Icon
(
Icons
.
account_circle_sharp
,
color:
Colors
.
grey
[
500
],
size:
screenize
.
width
*
0.01
,
),
),
const
SizedBox
(
const
SizedBox
(
width:
10
,
width:
30
,
),
const
Text
(
"Username"
,
style:
TextStyle
(
fontSize:
13
),
),
),
],
Column
(
),
crossAxisAlignment:
CrossAxisAlignment
.
start
,
const
SizedBox
(
height:
5
,),
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
Row
(
children:
[
children:
[
// ===============email pic==========
SizedBox
(
Row
(
height:
60
,
children:
[
width:
screenize
.
width
*
0.2
,
Icon
(
child:
TextFormField
(
Icons
.
email_outlined
,
controller:
usernameController
,
color:
Colors
.
grey
[
500
],
textAlign:
TextAlign
.
start
,
size:
screenize
.
width
*
0.01
,
validator:
(
value
){
if
(
value
==
null
||
value
.
isEmpty
){
return
"Username tidak boleh kosong"
;
}
return
null
;
},
decoration:
InputDecoration
(
labelText:
"Username"
,
labelStyle:
TextStyle
(
fontSize:
13
),
),
hintStyle:
const
TextStyle
(),
const
SizedBox
(
border:
OutlineInputBorder
(
width:
10
,
borderRadius:
BorderRadius
.
circular
(
5.0
),
),
const
Text
(
"Email PIC"
,
style:
TextStyle
(
fontSize:
13
),
),
],
),
const
SizedBox
(
height:
5
,
),
Row
(
children:
[
SizedBox
(
height:
60
,
width:
screenize
.
width
*
0.2
,
child:
TextFormField
(
controller:
emailPICController
,
textAlign:
TextAlign
.
start
,
validator:
(
value
)
{
if
(
value
==
null
||
value
.
isEmpty
)
{
return
"Email PIC tidak boleh kosong"
;
}
return
null
;
},
decoration:
InputDecoration
(
labelText:
"Email PIC"
,
labelStyle:
TextStyle
(
fontSize:
13
),
hintStyle:
const
TextStyle
(),
border:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
circular
(
5.0
),
)),
),
)
)
],
),
),
),
// ===============akhir email pic==========
)
],
),
],
],
),
),
const
SizedBox
(
height:
5
,),
Row
(
Row
(
children:
[
children:
[
Icon
(
Column
(
Icons
.
vpn_key_off_sharp
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
color:
Colors
.
grey
[
500
],
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
size:
screenize
.
width
*
0.01
,
children:
[
// ===============password==========
Row
(
children:
[
Icon
(
Icons
.
vpn_key_off_sharp
,
color:
Colors
.
grey
[
500
],
size:
screenize
.
width
*
0.01
,
),
const
SizedBox
(
width:
10
,
),
const
Text
(
"Password"
,
style:
TextStyle
(
fontSize:
13
),
),
],
),
const
SizedBox
(
height:
5
,
),
SizedBox
(
height:
60
,
width:
screenize
.
width
*
0.2
,
child:
TextFormField
(
controller:
passwordController
,
textAlign:
TextAlign
.
start
,
validator:
(
value
)
{
if
(
value
==
null
||
value
.
isEmpty
)
{
return
"Password tidak boleh kosong"
;
}
return
null
;
},
obscureText:
_isObscure
,
decoration:
InputDecoration
(
labelText:
"Password"
,
labelStyle:
TextStyle
(
fontSize:
13
),
suffixIcon:
IconButton
(
icon:
Icon
(
_isObscure
?
Icons
.
visibility
:
Icons
.
visibility_off
),
onPressed:
()
{
setState
(()
{
_isObscure
=
!
_isObscure
;
});
},
),
hintStyle:
const
TextStyle
(),
border:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
circular
(
5.0
)),
),
),
),
// ===============akhir password==========
],
),
),
const
SizedBox
(
const
SizedBox
(
width:
10
,
width:
30
,
),
const
Text
(
"Password"
,
style:
TextStyle
(
fontSize:
13
),
),
),
],
],
),
),
const
SizedBox
(
height:
5
,),
// Column(
SizedBox
(
// crossAxisAlignment: CrossAxisAlignment.start,
height:
60
,
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
width:
screenize
.
width
*
0.2
,
// children: [
child:
TextFormField
(
// // ===============password==========
controller:
pwController
,
// Row(
textAlign:
TextAlign
.
start
,
// children: [
validator:
(
value
){
// Icon(
if
(
value
==
null
||
value
.
isEmpty
){
// Icons.vpn_lock,
return
"Nama tidak boleh kosong"
;
// color: Colors.grey[500],
}
// size: screenize.width * 0.01,
return
null
;
// ),
},
// const SizedBox(
obscureText:
_isObscure
,
// width: 10,
decoration:
InputDecoration
(
// ),
labelText:
"Password"
,
// const Text(
labelStyle:
TextStyle
(
// "Latitude & Longitude PIC",
fontSize:
13
// style: TextStyle(fontSize: 13),
),
// ),
suffixIcon:
IconButton
(
// ],
icon:
Icon
(
_isObscure
// ),
?
Icons
.
visibility
// const SizedBox(
:
Icons
.
visibility_off
// height: 5,
),
// ),
onPressed:
(){
// Container(
setState
(()
{
// height: 50,
_isObscure
=
!
_isObscure
;
// width: screenize.width * 0.42,
});
// decoration: BoxDecoration(
},
// border: Border.all(color: Colors.grey),
),
// borderRadius: BorderRadius.circular(10),
hintStyle:
const
TextStyle
(),
// ),
border:
OutlineInputBorder
(
// child: Row(
borderRadius:
BorderRadius
.
circular
(
5.0
)
// mainAxisAlignment:
),
// MainAxisAlignment.spaceBetween,
),
// children: [
),
// Text(''),
),
// Container(
// height: 51,
// child: ClipRRect(
// borderRadius:
// BorderRadius.circular(10),
// child: ElevatedButton(
// onPressed: () {},
// child: Text('Set'))),
// ),
// ],
// )),
// // ===============akhir password==========
// ],
// ),
const
Spacer
(
const
Spacer
(
flex:
4
,
flex:
4
,
),
),
Row
(
Container
(
children:
[
padding:
EdgeInsets
.
only
(
left:
screenize
.
width
*
0.10
),
SizedBox
(
height:
screenize
.
width
*
0.03
,
height:
30
,
child:
Row
(
width:
screenize
.
width
*
0.09
,
children:
[
child:
ElevatedButton
(
SizedBox
(
onPressed:
(){
height:
30
,
Navigator
.
pushNamed
(
context
,
'/login'
);
width:
screenize
.
width
*
0.09
,
},
child:
ElevatedButton
(
child:
const
Text
(
"LOGIN"
),
onPressed:
()
{
Navigator
.
pushNamed
(
context
,
'/login'
);
},
child:
const
Text
(
"LOGIN"
),
),
),
),
),
SizedBox
(
SizedBox
(
width:
screenize
.
width
*
0.02
,
width:
screenize
.
width
*
0.02
,
),
SizedBox
(
height:
30
,
width:
screenize
.
width
*
0.09
,
child:
ElevatedButton
(
onPressed:
()
async
{
if
(
_formKey
.
currentState
!.
validate
()){
final
response
=
await
signUp
(
nameController
.
value
.
text
,
emailController
.
value
.
text
,
phoneController
.
value
.
text
,
usernameController
.
value
.
text
,
pwController
.
value
.
text
);
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
response
==
true
?
const
SnackBar
(
content:
Text
(
"Registrasi berhasil ! cek email untuk validasi"
),
backgroundColor:
Colors
.
green
,)
:
const
SnackBar
(
content:
Text
(
"Registrasi gagal"
),
backgroundColor:
Colors
.
red
,)
);
print
(
nameController
.
value
.
text
+
emailController
.
value
.
text
+
phoneController
.
value
.
text
+
usernameController
.
value
.
text
+
pwController
.
value
.
text
);
nameController
.
clear
();
emailController
.
clear
();
phoneController
.
clear
();
usernameController
.
clear
();
pwController
.
clear
();
}
},
child:
const
Text
(
"REGISTER"
),
),
),
)
SizedBox
(
],
height:
30
,
width:
screenize
.
width
*
0.09
,
child:
ElevatedButton
(
onPressed:
signUpUser
,
child:
const
Text
(
"REGISTER"
),
),
)
],
),
),
),
const
Spacer
(
const
Spacer
(
flex:
4
,
flex:
4
,
...
@@ -420,3 +637,4 @@ class _RegisterState extends State<Register> {
...
@@ -420,3 +637,4 @@ class _RegisterState extends State<Register> {
);
);
}
}
}
}
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