Skip to content
Snippets Groups Projects
Commit dcba6a34 authored by Maximilian Betz's avatar Maximilian Betz
Browse files

get gnss postion works

parent 446eb313
No related branches found
No related tags found
No related merge requests found
......@@ -31,3 +31,10 @@ A cross plattform project for android and ios to log events offline everywhere a
- Textfield to show current locally selected and offline available collection
- Button "get Collection devices from Sensor"
- Button "store Collection devices locally"
## GNSS
- Checkbox on add event page which activates GNSS locationing. A field shall signal "no fix" or presision in meter.
The fields lat, long, elevation are updated automatically if checkbox is checked.
\ No newline at end of file
......@@ -33,4 +33,6 @@
</application>
<!-- Required to fetch data from the internet. -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
</manifest>
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'datamodel.dart';
import 'dart:async';
import 'package:geolocator/geolocator.dart';
class AddEvent extends StatelessWidget {
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();
}
class _AddEventPageState extends State<AddEvent> {
final List<bool> _isSelected = [true];
@override
void initState() {
super.initState();
}
void _storeCurrentEvent() {
final EventStoreInstance storedEvents = EventStoreInstance();
......@@ -30,6 +56,7 @@ class AddEvent extends StatelessWidget {
final EventStoreInstance storedEvents = EventStoreInstance();
final EventCurrentInstance currentEvent = EventCurrentInstance();
return Scaffold(
appBar: AppBar(title: const Text("Add Event")),
body:
......@@ -51,12 +78,12 @@ class AddEvent extends StatelessWidget {
labelText: 'Event Type',
),
items:
eventTypes.store.map((EventType event) {
return DropdownMenuItem(
value: event.name,
child: Text(event.name),
);
}).toList(),
eventTypes.store.map((EventType event) {
return DropdownMenuItem(
value: event.name,
child: Text(event.name),
);
}).toList(),
onChanged: (value) {
currentEvent.store.type = value.toString();
}
......@@ -101,17 +128,36 @@ class AddEvent extends StatelessWidget {
decoration: const InputDecoration(
labelText: 'Elevation'
),
)
),
FutureBuilder<Position>(
future: fetchPosition(),
builder: (context, snapshot){
if (snapshot.hasData)
{
return Text(snapshot.data!.latitude.toString());
}
else{
return CircularProgressIndicator();
}
}
),
]),
bottomNavigationBar: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
FloatingActionButton(
heroTag: null,
onPressed: null,
tooltip: 'Get GNSS from device',
child: Icon(Icons.my_location),
ToggleButtons(
children: <Widget>[
Icon(Icons.my_location),
],
isSelected: _isSelected,
onPressed: (int index) {
setState(() {
_isSelected[index] = !_isSelected[index];
});
},
),
SizedBox(width: 50),
FloatingActionButton(
heroTag: null,
......
......@@ -93,6 +93,48 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
geolocator:
dependency: "direct main"
description:
name: geolocator
url: "https://pub.dartlang.org"
source: hosted
version: "8.1.1"
geolocator_android:
dependency: transitive
description:
name: geolocator_android
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.2"
geolocator_apple:
dependency: transitive
description:
name: geolocator_apple
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
geolocator_platform_interface:
dependency: transitive
description:
name: geolocator_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.2"
geolocator_web:
dependency: transitive
description:
name: geolocator_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
geolocator_windows:
dependency: transitive
description:
name: geolocator_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0"
http:
dependency: "direct main"
description:
......@@ -190,35 +232,35 @@ packages:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.12"
version: "2.0.13"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.10"
version: "2.0.11"
shared_preferences_ios:
dependency: transitive
description:
name: shared_preferences_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
version: "2.0.10"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
version: "2.1.0"
shared_preferences_macos:
dependency: transitive
description:
name: shared_preferences_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
version: "2.0.3"
shared_preferences_platform_interface:
dependency: transitive
description:
......@@ -239,7 +281,7 @@ packages:
name: shared_preferences_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
version: "2.1.0"
sky_engine:
dependency: transitive
description: flutter
......@@ -307,14 +349,14 @@ packages:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.6"
version: "2.3.11"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
version: "0.2.0+1"
sdks:
dart: ">=2.15.1 <3.0.0"
flutter: ">=2.5.0"
flutter: ">=2.8.0"
......@@ -32,7 +32,7 @@ dependencies:
shared_preferences: ^2.0.12
http: ^0.13.4
geolocator: ^8.1.1
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment