Skip to content

Commit

Permalink
split user location functions
Browse files Browse the repository at this point in the history
  • Loading branch information
josxha committed Oct 6, 2024
1 parent 4901cb6 commit 88632cb
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 195 deletions.
19 changes: 18 additions & 1 deletion example/lib/user_location_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,24 @@ class _UserLocationPageState extends State<UserLocationPage> {
onPressed: () async {
final status = await Permission.locationWhenInUse.request();
debugPrint(status.toString());
await _controller.trackUserLocation();
},
child: const Text(
'Get permission',
textAlign: TextAlign.center,
),
),
OutlinedButton(
onPressed: () async {
await _controller.enableLocation();
},
child: const Text(
'Enable location',
textAlign: TextAlign.center,
),
),
OutlinedButton(
onPressed: () async {
await _controller.trackLocation();
},
child: const Text(
'Track location',
Expand Down
7 changes: 5 additions & 2 deletions lib/src/map_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ abstract interface class MapController {
/// Add a new source to the map.
Future<void> addSource(Source source);

/// Track the user location and show on the map
Future<void> trackUserLocation({
/// Show the user location on the map
Future<void> enableLocation({
Duration fastestInterval = const Duration(milliseconds: 750),
Duration maxWaitTime = const Duration(milliseconds: 1000),
bool pulseFade = true,
Expand All @@ -58,6 +58,9 @@ abstract interface class MapController {
bool pulse = true,
});

/// Track the user location on the map
Future<void> trackLocation();

/// Add a new layer to the map. The source must be added before adding it to
/// the map.
///
Expand Down
Loading

0 comments on commit 88632cb

Please sign in to comment.