Skip to content

Commit

Permalink
lib: main: add distance and duration container
Browse files Browse the repository at this point in the history
Signed-off-by: Ayush Dubey <[email protected]>
  • Loading branch information
Ayushd70 committed Jul 19, 2021
1 parent ef8beaa commit 72433e0
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/.env.dart
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const String googleAPIkey = 'AIzaSyBlefMmsxW3lz0_wlTrCKAFZLsHXtgFufI'
const String googleAPIkey = 'AIzaSyBlefMmsxW3lz0_wlTrCKAFZLsHXtgFufI';
64 changes: 54 additions & 10 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,60 @@ class _MapScreenState extends State<MapScreen> {
),
],
),
body: GoogleMap(
myLocationButtonEnabled: false,
zoomControlsEnabled: false,
initialCameraPosition: _intitialCameraPosition,
onMapCreated: (controller) => _googleMapController = controller,
markers: {
if (_origin != null) _origin as Marker,
if (_destination != null) _destination as Marker,
},
onLongPress: _addMarker,
body: Stack(
alignment: Alignment.center,
children: [
GoogleMap(
myLocationButtonEnabled: false,
zoomControlsEnabled: false,
initialCameraPosition: _intitialCameraPosition,
onMapCreated: (controller) => _googleMapController = controller,
markers: {
if (_origin != null) _origin as Marker,
if (_destination != null) _destination as Marker,
},
polylines: {
if (_info != null)
Polyline(
polylineId: const PolylineId('overview_polyline'),
color: Colors.red,
width: 5,
points: _info!.polylinePoints
.map((e) => LatLng(e.latitude, e.longitude))
.toList(),
),
},
onLongPress: _addMarker,
),
if (_info != null)
Positioned(
top: 20.0,
child: Container(
padding: const EdgeInsets.symmetric(
vertical: 6.0,
horizontal: 12.0,
),
decoration: BoxDecoration(
color: Colors.yellowAccent,
borderRadius: BorderRadius.circular(20.0),
boxShadow: const [
BoxShadow(
color: Colors.black26,
offset: Offset(0, 2),
blurRadius: 6.0,
)
],
),
child: Text(
'${_info!.totalDistance}, ${_info!.totalDuration}',
style: const TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w600,
),
),
),
),
],
),
floatingActionButton: FloatingActionButton(
backgroundColor: Theme.of(context).primaryColor,
Expand Down

0 comments on commit 72433e0

Please sign in to comment.