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
15aee99e
Commit
15aee99e
authored
Oct 26, 2020
by
Dasun Madushanka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update timecard File
parent
e5dd4c31
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
0 deletions
+81
-0
MainAppDMT/lib/screens/timecard/timercard.dart
MainAppDMT/lib/screens/timecard/timercard.dart
+81
-0
No files found.
MainAppDMT/lib/screens/timecard/timercard.dart
0 → 100644
View file @
15aee99e
import
'dart:async'
;
import
'package:flutter/material.dart'
;
class
TimerCard
extends
StatefulWidget
{
const
TimerCard
({
Key
key
})
:
super
(
key:
key
);
@override
TimerCardState
createState
()
=>
TimerCardState
();
}
class
TimerCardState
extends
State
<
TimerCard
>
{
// The timer's value shown on app's UI.
int
_timerValue
=
0
;
bool
_paused
=
true
;
// A stream that updates every second. The stream's value is the number of
// seconds elapsed since the app is started. We simply print this stream value
// out in command-line. The value shown on UI is this._timerValue.
final
Stream
<
int
>
_periodicStream
=
Stream
.
periodic
(
Duration
(
milliseconds:
1000
),
(
i
)
=>
i
);
// Record of the latest stream value that we saw. Because the StreamBuilder is
// rebuilt when we call setState(), and in the re-build we shouldn't increment
// this._timerValue if the latest snapshot's value hasn't changed.
int
_previousStreamValue
=
0
;
@override
Widget
build
(
BuildContext
context
)
{
return
Container
(
alignment:
Alignment
.
center
,
margin:
EdgeInsets
.
all
(
8
),
child:
StreamBuilder
(
stream:
this
.
_periodicStream
,
builder:
(
BuildContext
context
,
AsyncSnapshot
<
int
>
snapshot
)
{
if
(
snapshot
.
hasData
)
{
if
(
snapshot
.
data
!=
this
.
_previousStreamValue
)
{
print
(
'Latest snapshot from stream:
${snapshot.data}
'
);
this
.
_previousStreamValue
=
snapshot
.
data
;
if
(!
_paused
)
{
this
.
_timerValue
++;
}
}
}
return
Column
(
mainAxisSize:
MainAxisSize
.
min
,
children:
<
Widget
>[
Card
(
child:
_buildTimerUI
()),
],
);
},
),
);
}
Widget
_buildTimerUI
()
{
return
Column
(
children:
<
Widget
>[
Text
(
'
$_timerValue
'
,
style:
Theme
.
of
(
context
).
textTheme
.
headline4
,
),
ButtonBar
(
mainAxisSize:
MainAxisSize
.
min
,
children:
<
Widget
>[
IconButton
(
icon:
Icon
(
this
.
_paused
?
Icons
.
play_arrow
:
Icons
.
pause
),
onPressed:
()
=>
setState
(()
=>
this
.
_paused
=
!
this
.
_paused
),
),
IconButton
(
icon:
Icon
(
Icons
.
stop
),
onPressed:
()
=>
setState
(
()
{
this
.
_timerValue
=
0
;
this
.
_paused
=
true
;
},
),
),
],
),
],
);
}
}
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