Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PROG2900
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sara Savanovic Djordjevic
PROG2900
Commits
04a9d20e
Commit
04a9d20e
authored
1 year ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
update: attempt at snackBar alert, not tested
parent
d529f3d0
No related branches found
Branches containing commit
No related tags found
2 merge requests
!9
Clhp map
,
!8
Clhp map
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/lib/pages/default_page.dart
+18
-4
18 additions, 4 deletions
app/lib/pages/default_page.dart
with
18 additions
and
4 deletions
app/lib/pages/default_page.dart
+
18
−
4
View file @
04a9d20e
...
...
@@ -23,6 +23,8 @@ class _DefaultPageState extends State<DefaultPage> {
late
Future
<
List
<
Measurement
>>
markerListFuture
;
late
Future
<
Uint8List
>
relationFuture
;
/// Fetch measurement and relation data, check server connection, and
/// start a request timer
@override
void
initState
()
{
super
.
initState
();
...
...
@@ -37,9 +39,11 @@ class _DefaultPageState extends State<DefaultPage> {
throw
Exception
(
"Failed to fetch measurements:
$error
"
);
});
if
(
!
serverConnection
)
{
_showConnectionMessage
();
}
relationFuture
=
fetchRelation
();
//relationFuture = Future.value(Uint8List(0));
// Schedule fetchMarkerData to run periodically based on fetchInterval from consts
const
Duration
interval
=
Duration
(
minutes:
fetchInterval
);
// NB fetchInterval value to be determined
...
...
@@ -48,7 +52,17 @@ class _DefaultPageState extends State<DefaultPage> {
});
}
// Fetch-interval timer
/// Display a message for 5 seconds informing the user
/// of lacking server connection
void
_showConnectionMessage
()
{
const
snackBar
=
SnackBar
(
content:
Text
(
'Failed to connect to the server. Information about'
'ice safety could be outdated!'
),
duration:
Duration
(
seconds:
5
),
);
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
snackBar
);
}
/// Timer for resending requests to server
@override
void
dispose
()
{
// Cancel timer on widget termination
...
...
@@ -93,8 +107,8 @@ class _DefaultPageState extends State<DefaultPage> {
}
else
if
(
snapshot
.
hasError
)
{
return
Center
(
child:
Text
(
'Error:
${snapshot.error}
'
));
}
else
{
if
(
!
serverConnection
)
{
// NB: implement
alert
print
(
"Failed to connect to server"
);
if
(
!
serverConnection
)
{
// NB: implement
dialogue box
print
(
"Failed to connect to server"
);
// Here...
}
// Display default page once all data is loaded from server
List
<
Measurement
>
markerList
=
snapshot
.
data
!
[
0
]
as
List
<
Measurement
>;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment