flutter_google_track_and_trace/lib/src/controller.dart

57 lines
1.2 KiB
Dart
Raw Normal View History

2021-09-28 08:18:14 +02:00
part of google_track_trace;
2021-09-29 10:07:56 +02:00
class TrackTraceController extends ChangeNotifier {
2021-09-29 12:18:53 +02:00
GoogleMapController? _mapController;
Marker _startPosition;
Marker _destinationPosition;
TrackTraceRoute? _route;
2021-09-28 08:18:14 +02:00
2021-09-29 10:07:56 +02:00
TrackTraceController(Marker start, Marker destination)
2021-09-29 12:18:53 +02:00
: _startPosition = start,
_destinationPosition = destination;
2021-09-28 08:18:14 +02:00
2021-09-29 10:07:56 +02:00
set start(Marker start) {
2021-09-29 12:18:53 +02:00
_startPosition = start;
2021-09-29 10:07:56 +02:00
notifyListeners();
}
2021-09-28 08:18:14 +02:00
2021-09-29 10:07:56 +02:00
set end(Marker end) {
2021-09-29 12:18:53 +02:00
_destinationPosition = end;
2021-09-29 10:07:56 +02:00
notifyListeners();
}
2021-09-28 08:18:14 +02:00
2021-09-29 12:18:53 +02:00
Marker get start => _startPosition;
2021-09-28 08:18:14 +02:00
2021-09-29 12:18:53 +02:00
Marker get end => _destinationPosition;
2021-09-29 10:07:56 +02:00
2021-09-29 12:18:53 +02:00
TrackTraceRoute? get route => _route;
2021-09-29 10:07:56 +02:00
2021-09-29 12:18:53 +02:00
set route(TrackTraceRoute? newRoute) {
_route = newRoute;
2021-09-29 10:07:56 +02:00
notifyListeners();
2021-09-28 08:18:14 +02:00
}
2021-09-29 12:18:53 +02:00
set mapController(GoogleMapController? controller) {
2021-09-29 10:07:56 +02:00
_mapController = controller;
2021-09-28 08:18:14 +02:00
}
2021-09-29 10:07:56 +02:00
2021-09-29 12:18:53 +02:00
GoogleMapController? get mapController => _mapController;
}
class TrackTraceRoute {
/// route duration in seconds
int duration = 0;
/// route distance in meters
int distance = 0;
/// route edge points
List<PointLatLng> line;
TrackTraceRoute(
int durationValue, int distanceValue, List<PointLatLng> lineValue)
: duration = durationValue,
distance = distanceValue,
line = lineValue;
2021-09-28 08:18:14 +02:00
}