-
Notifications
You must be signed in to change notification settings - Fork 0
/
track_device_location_route.dart
57 lines (52 loc) · 1.95 KB
/
track_device_location_route.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import 'package:design_system_flutter/design_system_flutter.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:sbb_maps_example/env.dart';
import 'package:sbb_maps_example/theme_provider.dart';
import 'package:sbb_maps_flutter/sbb_maps_flutter.dart';
final _kCameraZurich = SBBCameraUpdate.newLatLngZoom(const LatLng(47.3769, 8.5417), 15.0);
class TrackDeviceLocationRoute extends StatefulWidget {
const TrackDeviceLocationRoute({super.key});
@override
State<TrackDeviceLocationRoute> createState() => _TrackDeviceLocationRouteState();
}
class _TrackDeviceLocationRouteState extends State<TrackDeviceLocationRoute> {
late SBBMapController controller;
@override
Widget build(BuildContext context) {
final mapStyler = SBBRokasMapStyler.full(
apiKey: Env.journeyMapsTilesApiKey,
isDarkMode: Provider.of<ThemeProvider>(context).isDark,
);
return Scaffold(
appBar: const SBBHeader(title: 'Track Device'),
body: SBBMap(
isMyLocationEnabled: true,
mapStyler: mapStyler,
onMapLocatorAvailable: (locator) => locator.trackDeviceLocation(),
onMapCreated: (c) => controller = c,
builder: (context) => Align(
alignment: Alignment.topRight,
child: Padding(
padding: const EdgeInsets.only(
top: sbbDefaultSpacing,
right: sbbDefaultSpacing / 2,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.start,
children: [
const SBBMapMyLocationButton(),
const SizedBox(height: sbbDefaultSpacing),
SBBMapIconButton(
onPressed: () => controller.animateCameraMove(cameraUpdate: _kCameraZurich),
icon: SBBIcons.station_small,
)
],
),
),
),
),
);
}
}