mirror of
https://github.com/Iconica-Development/flutter_google_track_and_trace.git
synced 2025-05-19 13:13:44 +02:00
Merge pull request #1 from Iconica-Development/bugfix/move-away-from-then
Move away from .then and use await instead
This commit is contained in:
commit
960d5fb597
3 changed files with 46 additions and 52 deletions
|
@ -130,33 +130,31 @@ class _TrackTraceDemoState extends State<TrackTraceDemo> {
|
|||
);
|
||||
}
|
||||
|
||||
void loadBitmapImages() {
|
||||
rootBundle.load('assets/profile_picture.png').then((value) {
|
||||
convertBytesToCustomBitmapDescriptor(
|
||||
value.buffer.asUint8List(),
|
||||
Future<void> loadBitmapImages() async {
|
||||
var loadedPicture = await rootBundle.load('assets/profile_picture.png');
|
||||
var bitmap = await convertBytesToCustomBitmapDescriptor(
|
||||
loadedPicture.buffer.asUint8List(),
|
||||
size: 80,
|
||||
addBorder: true,
|
||||
borderColor: Colors.grey,
|
||||
title: 'Alex',
|
||||
titleBackgroundColor: Color(0xffff7884),
|
||||
).then((bitmap) {
|
||||
);
|
||||
|
||||
startMarkerIcon = bitmap;
|
||||
BitmapDescriptor.fromAssetImage(
|
||||
var bitmapDescriptor = await BitmapDescriptor.fromAssetImage(
|
||||
ImageConfiguration(size: Size(100, 100)),
|
||||
'assets/ic_location_on.png',
|
||||
).then((value) {
|
||||
);
|
||||
setState(() {
|
||||
destinationMarkerIcon = value;
|
||||
destinationMarkerIcon = bitmapDescriptor;
|
||||
controller?.end = Marker(
|
||||
anchor: Offset(0.5, 0.5),
|
||||
markerId: MarkerId('Bestemming Locatie'),
|
||||
position: LatLng(52.364709, 4.877157),
|
||||
icon: value,
|
||||
icon: bitmapDescriptor,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void getRandomPointOnMap() {
|
||||
|
|
|
@ -227,32 +227,28 @@ class _GoogleTrackTraceMapState extends State<GoogleTrackTraceMap> {
|
|||
}
|
||||
}
|
||||
|
||||
void calculateRoute() {
|
||||
Future<void> calculateRoute() async {
|
||||
if (controller.route == null || checkTargetMoved()) {
|
||||
DirectionsRepository() // TODO(freek): refactor this away
|
||||
var directions =
|
||||
await DirectionsRepository() // TODO(freek): refactor this away
|
||||
.getDirections(
|
||||
origin: controller.start.position,
|
||||
destination: controller.end.position,
|
||||
mode: widget.travelMode,
|
||||
key: widget.googleAPIKey,
|
||||
)
|
||||
.then(
|
||||
(Directions? directions) => {
|
||||
if (directions != null)
|
||||
{
|
||||
);
|
||||
if (directions != null) {
|
||||
controller.route = TrackTraceRoute(
|
||||
directions.totalDuration,
|
||||
directions.totalDistance,
|
||||
directions.polylinePoints,
|
||||
),
|
||||
checkDestinationCloseBy(),
|
||||
controller.recenterCamera(),
|
||||
);
|
||||
checkDestinationCloseBy();
|
||||
controller.recenterCamera();
|
||||
setState(() {
|
||||
lastRouteUpdate = DateTime.now();
|
||||
}),
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: google_track_trace
|
||||
description: An Iconica Flutter pluginin for Track & Trace Package
|
||||
version: 1.0.1
|
||||
version: 1.0.2
|
||||
|
||||
environment:
|
||||
sdk: ">=2.14.0 <3.0.0"
|
||||
|
|
Loading…
Reference in a new issue