Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MobileEventLog
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
Container 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
Data-Logistics-Support
MobileEventLog
Commits
bf1987b6
Commit
bf1987b6
authored
3 years ago
by
Maximilian Betz
Browse files
Options
Downloads
Patches
Plain Diff
gnss stream update working
parent
dcba6a34
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/addevent.dart
+101
-28
101 additions, 28 deletions
lib/addevent.dart
with
101 additions
and
28 deletions
lib/addevent.dart
+
101
−
28
View file @
bf1987b6
...
...
@@ -4,20 +4,6 @@ import 'datamodel.dart';
import
'dart:async'
;
import
'package:geolocator/geolocator.dart'
;
Future
<
Position
>
fetchPosition
()
async
{
Position
position
=
await
Geolocator
.
getCurrentPosition
(
desiredAccuracy:
LocationAccuracy
.
high
);
print
(
position
.
longitude
);
//Output: 80.24599079
print
(
position
.
latitude
);
//Output: 29.6593457
print
(
position
.
altitude
);
String
long
=
position
.
longitude
.
toString
();
String
lat
=
position
.
latitude
.
toString
();
String
alt
=
position
.
altitude
.
toString
();
return
position
;
}
class
AddEvent
extends
StatefulWidget
{
@override
State
<
AddEvent
>
createState
()
=
>
_AddEventPageState
();
...
...
@@ -25,9 +11,92 @@ class AddEvent extends StatefulWidget {
class
_AddEventPageState
extends
State
<
AddEvent
>
{
final
List
<
bool
>
_isSelected
=
[
true
];
bool
servicestatus
=
false
;
bool
haspermission
=
false
;
late
LocationPermission
permission
;
late
Position
position
;
late
String
long
=
""
;
late
String
lat
=
""
;
late
String
alt
=
""
;
late
String
accuracy
=
""
;
late
StreamSubscription
<
Position
>
positionStream
;
LocationSettings
locationSettings
=
const
LocationSettings
(
accuracy:
LocationAccuracy
.
high
,
distanceFilter:
0
,
);
getLocation
()
async
{
position
=
await
Geolocator
.
getCurrentPosition
(
desiredAccuracy:
LocationAccuracy
.
high
);
print
(
'Get Location: Lat:'
+
position
.
latitude
.
toString
()
+
' Long:'
+
position
.
longitude
.
toString
()
+
' Alt:'
+
position
.
altitude
.
toString
());
long
=
position
.
longitude
.
toString
();
lat
=
position
.
latitude
.
toString
();
alt
=
position
.
altitude
.
toString
();
accuracy
=
position
.
accuracy
.
toString
();
setState
(()
{
//refresh UI
});
StreamSubscription
<
Position
>
positionStream
=
Geolocator
.
getPositionStream
(
locationSettings:
locationSettings
)
.
listen
((
Position
position
)
{
print
(
'Get Location: Lat:'
+
position
.
latitude
.
toString
()
+
' Long:'
+
position
.
longitude
.
toString
()
+
' Alt:'
+
position
.
altitude
.
toString
());
long
=
position
.
longitude
.
toString
();
lat
=
position
.
latitude
.
toString
();
alt
=
position
.
altitude
.
toString
();
accuracy
=
position
.
accuracy
.
toString
();
setState
(()
{
//refresh UI on update
});
});
}
checkGnssPermission
()
async
{
print
(
"CheckGnssPermission"
);
servicestatus
=
await
Geolocator
.
isLocationServiceEnabled
();
if
(
servicestatus
){
permission
=
await
Geolocator
.
checkPermission
();
if
(
permission
==
LocationPermission
.
denied
)
{
permission
=
await
Geolocator
.
requestPermission
();
if
(
permission
==
LocationPermission
.
denied
)
{
print
(
'Location permissions are denied'
);
}
else
if
(
permission
==
LocationPermission
.
deniedForever
){
print
(
'Location permissions are permanently denied'
);
}
else
{
haspermission
=
true
;
}
}
else
{
haspermission
=
true
;
}
if
(
haspermission
){
print
(
'Location permissions granted'
);
setState
(()
{
//refresh the UI
});
getLocation
();
}
}
else
{
print
(
"GPS Service is not enabled, turn on GPS location"
);
}
setState
(()
{
//refresh the UI
});
}
@override
void
initState
()
{
checkGnssPermission
();
super
.
initState
();
}
...
...
@@ -115,37 +184,42 @@ class _AddEventPageState extends State<AddEvent> {
},
),
TextFormField
(
initialValue:
lat
,
decoration:
const
InputDecoration
(
labelText:
'Latitude'
),
),
TextFormField
(
initialValue:
long
,
decoration:
const
InputDecoration
(
labelText:
'Longitude'
),
),
TextFormField
(
initialValue:
alt
,
decoration:
const
InputDecoration
(
labelText:
'Elevation'
),
),
FutureBuilder
<
Position
>(
future:
fetchPosition
(),
builder:
(
context
,
snapshot
){
if
(
snapshot
.
hasData
)
{
return
Text
(
snapshot
.
data
!.
latitude
.
toString
());
}
else
{
return
CircularProgressIndicator
();
}
}
),
//FutureBuilder<Position>(
// future: fetchPosition(),
// builder: (context, snapshot){
// if (snapshot.hasData)
// {
// return Text(snapshot.data!.latitude.toString());
// }
// else{
// return CircularProgressIndicator();
// }
// }
//),
Text
(
'Lat:'
+
lat
),
]),
bottomNavigationBar:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
end
,
children:
[
Text
(
'No-Fix'
),
SizedBox
(
width:
50
),
ToggleButtons
(
children:
<
Widget
>[
Icon
(
Icons
.
my_location
),
...
...
@@ -157,7 +231,6 @@ class _AddEventPageState extends State<AddEvent> {
});
},
),
SizedBox
(
width:
50
),
FloatingActionButton
(
heroTag:
null
,
...
...
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