Skip to content

Commit d48347e

Browse files
committed
Open default map after clicking address button
1 parent e276652 commit d48347e

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

lib/studySpacePage.dart

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:collection/collection.dart';
22
import 'package:flutter/foundation.dart';
33
import 'package:flutter/material.dart';
4+
import 'package:map_launcher/map_launcher.dart';
45

56
import 'MaterialIconsSelected.dart';
67
import 'main.dart';
@@ -171,10 +172,21 @@ class StudySpacePage extends StatelessWidget {
171172
height:
172173
Theme.of(context).textTheme.bodyLarge!.fontSize! / 2),
173174
OutlinedButton.icon(
174-
onPressed: () {
175+
onPressed: () async {
175176
if (kDebugMode) {
176177
print("Tapped on the address of ${studySpace.title}.");
177178
}
179+
final availableMaps = await MapLauncher.installedMaps;
180+
if (kDebugMode) {
181+
print(availableMaps);
182+
}
183+
184+
await availableMaps.first.showDirections(
185+
destinationTitle: studySpace.title,
186+
destination: Coords(studySpace.buildingPosition.latitude,
187+
studySpace.buildingPosition.longitude),
188+
directionsMode: DirectionsMode.walking,
189+
);
178190
},
179191
icon: Icon(MaterialIconsSelected.place,
180192
size: Theme.of(context).textTheme.bodyLarge!.fontSize!),

pubspec.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,13 @@ packages:
417417
url: "https://pub.dartlang.org"
418418
source: hosted
419419
version: "1.0.2"
420+
map_launcher:
421+
dependency: "direct main"
422+
description:
423+
name: map_launcher
424+
url: "https://pub.dartlang.org"
425+
source: hosted
426+
version: "2.2.1+2"
420427
matcher:
421428
dependency: transitive
422429
description:

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies:
1919
json_serializable: ^6.1.5
2020
flutter_native_splash: ^2.1.3+1
2121
geolocator: ^8.2.0
22+
map_launcher: ^2.2.1+2
2223

2324
dev_dependencies:
2425
flutter_test:

0 commit comments

Comments
 (0)