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
aaea8849
Commit
aaea8849
authored
Sep 05, 2022
by
r.manan@eksad.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
widget form verifikasi
parent
c46ba368
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
148 additions
and
0 deletions
+148
-0
verifikasi.dart
lib/widget/verifikasi.dart
+131
-0
pubspec.lock
pubspec.lock
+14
-0
pubspec.yaml
pubspec.yaml
+3
-0
No files found.
lib/widget/verifikasi.dart
0 → 100644
View file @
aaea8849
import
'package:flutter/material.dart'
;
class
FormVerifikasi
extends
StatefulWidget
{
const
FormVerifikasi
({
Key
?
key
})
:
super
(
key:
key
);
@override
_FormVerifikasiState
createState
()
=>
_FormVerifikasiState
();
}
class
_FormVerifikasiState
extends
State
<
FormVerifikasi
>
{
// apa aja yang mau diminta?
final
_formKey
=
GlobalKey
<
FormState
>();
String
_userEmail
=
''
;
String
_userName
=
''
;
String
_password
=
''
;
String
_confirmPassword
=
''
;
// Fungsi ini ke trigger ketika ada user yang pencet tombol verif
void
_trySubmitForm
()
{
final
bool
?
isValid
=
_formKey
.
currentState
?.
validate
();
if
(
isValid
==
true
)
{
debugPrint
(
'Everything looks good!'
);
debugPrint
(
_userEmail
);
debugPrint
(
_userName
);
debugPrint
(
_password
);
debugPrint
(
_confirmPassword
);
/*
lanjut buat kirim HTTP requests, atau save ke database SQL, dll.
*/
}
}
@override
Widget
build
(
BuildContext
context
)
{
return
Container
(
color:
Colors
.
blueAccent
,
alignment:
Alignment
.
center
,
child:
Center
(
child:
Card
(
margin:
const
EdgeInsets
.
symmetric
(
horizontal:
35
),
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
20
),
child:
Form
(
key:
_formKey
,
child:
Column
(
mainAxisSize:
MainAxisSize
.
min
,
children:
[
/// Email
TextFormField
(
decoration:
const
InputDecoration
(
labelText:
'Email'
),
validator:
(
value
)
{
if
(
value
==
null
||
value
.
trim
().
isEmpty
)
{
return
'Please enter your email address'
;
}
// Check if the entered email has the right format
if
(!
RegExp
(
r'\S+@\S+\.\S+'
).
hasMatch
(
value
))
{
return
'Please enter a valid email address'
;
}
// Return null if the entered email is valid
return
null
;
},
onChanged:
(
value
)
=>
_userEmail
=
value
,
),
/// username
TextFormField
(
decoration:
const
InputDecoration
(
labelText:
'Username'
),
validator:
(
value
)
{
if
(
value
==
null
||
value
.
trim
().
isEmpty
)
{
return
'This field is required'
;
}
if
(
value
.
trim
().
length
<
4
)
{
return
'Username must be at least 4 characters in length'
;
}
// Return null if the entered username is valid
return
null
;
},
onChanged:
(
value
)
=>
_userName
=
value
,
),
/// Password
TextFormField
(
decoration:
const
InputDecoration
(
labelText:
'Password'
),
obscureText:
true
,
validator:
(
value
)
{
if
(
value
==
null
||
value
.
trim
().
isEmpty
)
{
return
'This field is required'
;
}
if
(
value
.
trim
().
length
<
8
)
{
return
'Password must be at least 8 characters in length'
;
}
// Return null if the entered password is valid
return
null
;
},
onChanged:
(
value
)
=>
_password
=
value
,
),
/// Confirm Password
TextFormField
(
decoration:
const
InputDecoration
(
labelText:
'Confirm Password'
),
obscureText:
true
,
validator:
(
value
)
{
if
(
value
==
null
||
value
.
isEmpty
)
{
return
'This field is required'
;
}
if
(
value
!=
_password
)
{
return
'Confimation password does not match the entered password'
;
}
return
null
;
},
onChanged:
(
value
)
=>
_confirmPassword
=
value
,
),
const
SizedBox
(
height:
20
),
Container
(
alignment:
Alignment
.
centerRight
,
child:
OutlinedButton
(
onPressed:
_trySubmitForm
,
child:
const
Text
(
'Verification'
)))
],
)),
),
),
),
);
}
}
pubspec.lock
View file @
aaea8849
...
@@ -142,6 +142,20 @@ packages:
...
@@ -142,6 +142,20 @@ packages:
url: "https://pub.dartlang.org"
url: "https://pub.dartlang.org"
source: hosted
source: hosted
version: "10.1.0"
version: "10.1.0"
form_field_validator:
dependency: "direct main"
description:
name: form_field_validator
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
form_validator:
dependency: "direct main"
description:
name: form_validator
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
google_fonts:
google_fonts:
dependency: "direct main"
dependency: "direct main"
description:
description:
...
...
pubspec.yaml
View file @
aaea8849
...
@@ -36,6 +36,9 @@ dependencies:
...
@@ -36,6 +36,9 @@ dependencies:
intl
:
^0.17.0
intl
:
^0.17.0
dropdown_search
:
^5.0.2
dropdown_search
:
^5.0.2
easy_sidemenu
:
^0.3.1
easy_sidemenu
:
^0.3.1
form_validator
:
^1.0.0
form_field_validator
:
^1.0.1
flutter_web_plugins
:
flutter_web_plugins
:
sdk
:
flutter
sdk
:
flutter
...
...
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