mirror of
https://github.com/timokz/flutter-vienna-hackathon-25.git
synced 2025-11-08 21:24:20 +01:00
38 lines
1.3 KiB
Dart
38 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:location/location.dart';
|
|
import 'package:wien_talks_flutter/location_mgr.dart';
|
|
|
|
class GetLocationWidget extends StatelessWidget {
|
|
const GetLocationWidget({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
children: [
|
|
FutureBuilder(
|
|
future: LocationMgr().startup(),
|
|
builder: (BuildContext context, AsyncSnapshot<String?> snapshot) {
|
|
switch (snapshot.connectionState) {
|
|
case ConnectionState.waiting:
|
|
return CircularProgressIndicator();
|
|
case ConnectionState.done:
|
|
{
|
|
if (snapshot.hasData) {
|
|
// Error occured
|
|
return Text(snapshot.data.toString());
|
|
} else {
|
|
return Text("No data -> OK");
|
|
}
|
|
}
|
|
default:
|
|
if (snapshot.hasError) {
|
|
return Text('Error: ${snapshot.error}');
|
|
}
|
|
return Text("OK");
|
|
}
|
|
}),
|
|
StreamBuilder(stream: LocationMgr().stream, builder: (BuildContext context, AsyncSnapshot<LocationData> snapshot) => Text(snapshot.data.toString())),
|
|
],
|
|
);
|
|
}
|
|
}
|