Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
CHILD INTELLIGENT ASSESSMENT TOOL
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2020-046
CHILD INTELLIGENT ASSESSMENT TOOL
Commits
346a9d54
Commit
346a9d54
authored
Oct 28, 2020
by
Dasun Madushanka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update form_m
parent
e86359f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
126 additions
and
0 deletions
+126
-0
MainAppDMT/lib/screens/Form/multi_form.dart
MainAppDMT/lib/screens/Form/multi_form.dart
+126
-0
No files found.
MainAppDMT/lib/screens/Form/multi_form.dart
0 → 100644
View file @
346a9d54
import
'package:DMTI_app/screens/Form/user.dart'
;
import
'package:DMTI_app/screens/product/products_screen.dart'
;
import
'package:flutter/material.dart'
;
import
'empty_state.dart'
;
import
'form.dart'
;
class
MultiForm
extends
StatefulWidget
{
@override
_MultiFormState
createState
()
=>
_MultiFormState
();
}
class
_MultiFormState
extends
State
<
MultiForm
>
{
List
<
UserForm
>
users
=
[];
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
elevation:
.
0
,
leading:
IconButton
(
onPressed:
()
{
Navigator
.
of
(
context
)
.
push
(
MaterialPageRoute
(
builder:
(
c
)
=>
ProductsScreen
()));
},
icon:
Icon
(
Icons
.
home
,
),
),
title:
Text
(
'Patients Records'
),
actions:
<
Widget
>[
FlatButton
(
child:
Text
(
'Save'
),
textColor:
Colors
.
white
,
onPressed:
onSave
,
)
],
),
body:
Container
(
decoration:
BoxDecoration
(
gradient:
LinearGradient
(
colors:
[
Color
(
0xFF30C1FF
),
Color
(
0xFF2AA7DC
),
],
begin:
Alignment
.
topCenter
,
end:
Alignment
.
bottomCenter
,
),
),
child:
users
.
length
<=
0
?
Center
(
child:
EmptyState
(
title:
'No Records'
,
message:
'Add form by tapping add button below'
,
),
)
:
ListView
.
builder
(
addAutomaticKeepAlives:
true
,
itemCount:
users
.
length
,
itemBuilder:
(
_
,
i
)
=>
users
[
i
],
),
),
floatingActionButton:
FloatingActionButton
(
child:
Icon
(
Icons
.
add
),
onPressed:
onAddForm
,
foregroundColor:
Colors
.
white
,
),
);
}
///on form user deleted
void
onDelete
(
User
_user
)
{
setState
(()
{
var
find
=
users
.
firstWhere
(
(
it
)
=>
it
.
user
==
_user
,
orElse:
()
=>
null
,
);
if
(
find
!=
null
)
users
.
removeAt
(
users
.
indexOf
(
find
));
});
}
///on add form
void
onAddForm
()
{
setState
(()
{
var
_user
=
User
();
users
.
add
(
UserForm
(
user:
_user
,
onDelete:
()
=>
onDelete
(
_user
),
));
});
}
///on save forms
void
onSave
()
{
if
(
users
.
length
>
0
)
{
var
allValid
=
true
;
users
.
forEach
((
form
)
=>
allValid
=
allValid
&&
form
.
isValid
());
if
(
allValid
)
{
var
data
=
users
.
map
((
it
)
=>
it
.
user
).
toList
();
Navigator
.
push
(
context
,
MaterialPageRoute
(
fullscreenDialog:
true
,
builder:
(
_
)
=>
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'List of Users'
),
),
body:
ListView
.
builder
(
itemCount:
data
.
length
,
itemBuilder:
(
_
,
i
)
=>
ListTile
(
leading:
CircleAvatar
(
child:
Text
(
data
[
i
].
fullName
.
substring
(
0
,
1
)),
),
title:
Text
(
data
[
i
].
fullName
),
subtitle:
Text
(
data
[
i
].
mentalage
,
),
),
),
),
),
);
}
}
}
}
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