diff --git a/lib/model/workshopCreator.dart b/lib/model/workshopCreator.dart index b9aadb4d..c1c7facd 100644 --- a/lib/model/workshopCreator.dart +++ b/lib/model/workshopCreator.dart @@ -12,6 +12,8 @@ class WorkshopCreater { String date; String time; String location; + String latitude; + String longitude; String audience; List contactIds = []; Map contactNameofId = {}; @@ -55,6 +57,8 @@ class WorkshopCreater { ..date = workshop.date ..time = workshop.time ..location = workshop.location + ..latitude = workshop.latitude + ..longitude = workshop.longitude ..audience = workshop.audience ..resources = BuiltList([1]).toBuilder() ..contacts = workshop.contactIds.build().toBuilder() @@ -88,6 +92,8 @@ class WorkshopCreater { ..date = workshop.date ..time = workshop.time ..location = workshop.location + ..latitude = workshop.latitude + ..longitude = workshop.longitude ..audience = workshop.audience); await AppConstants.service diff --git a/lib/pages/create.dart b/lib/pages/create.dart index a7a0f043..fdd0cdbe 100644 --- a/lib/pages/create.dart +++ b/lib/pages/create.dart @@ -115,6 +115,8 @@ class _CreateScreenState extends State { widget.workshopData.tags.forEach((tag) { this._workshop.tagNameofId[tag.id] = tag.tag_name; }); + this._workshop.latitude = widget.workshopData.latitude; + this._workshop.longitude = widget.workshopData.longitude; } else { _workshop = WorkshopCreater(); } @@ -269,15 +271,45 @@ class _CreateScreenState extends State { ), ], ), - TextFormField( - autovalidate: true, - decoration: InputDecoration(labelText: 'Location'), - controller: this._locationController, - validator: (value) { - return null; - }, - onSaved: (val) => - setState(() => _workshop.location = val)), + Row( + children: [ + Expanded( + child: TextFormField( + autovalidate: true, + decoration: InputDecoration( + labelText: 'Location', + ), + controller: this._locationController, + validator: (value) { + return null; + }, + onSaved: (val) => + setState(() => _workshop.location = val)), + ), + RaisedButton( + child: Icon(Icons.map), + onPressed: () async { + final location = await Navigator.of(context) + .pushNamed('/mapScreen', + arguments: {'fromWorkshopCreate': true}) + as List; + this._workshop.latitude = + location == null ? null : location[0]; + this._workshop.longitude = + location == null ? null : location[1]; + if (this._locationController.text == '') + this._locationController.text = + location == null ? null : location[2]; + setState(() {}); + }, + ), + ], + ), + this._workshop.latitude != null && + this._workshop.longitude != null + ? Text( + '${this._workshop.latitude}, ${this._workshop.longitude}') + : Container(), TextFormField( autovalidate: true, decoration: InputDecoration(labelText: 'Audience'), @@ -323,7 +355,7 @@ class _CreateScreenState extends State { this._searchPost) .catchError((onError) { print( - 'Error whlie fetching search results: $onError'); + 'Error while fetching search results: $onError'); }).then((result) { if (result != null) this._searchedProfileresult = result.body; @@ -494,7 +526,6 @@ class _CreateScreenState extends State { print('Error while fetching all tags $onError'); }).then((result) { if (result != null) { - print(result.body.runtimeType); this._allTagsOfClub = result.body.club_tags; this._allTagDataShow = true; this._allTagDataFetched = true; @@ -539,8 +570,6 @@ class _CreateScreenState extends State { .tagNameofId .keys .toList()[index]; - print( - '$_id : ${this._workshop.tagNameofId[_id]}'); return Container( padding: EdgeInsets.all(2), child: Row( diff --git a/lib/screens/home/home_widgets.dart b/lib/screens/home/home_widgets.dart index 449a9e11..a36514fa 100644 --- a/lib/screens/home/home_widgets.dart +++ b/lib/screens/home/home_widgets.dart @@ -221,8 +221,12 @@ class HomeWidgets { ), ) .then((value) => reload()); - if (fabKey.currentState.isOpen) { - fabKey.currentState.close(); + try { + if (fabKey.currentState.isOpen) { + fabKey.currentState.close(); + } + } catch (e) { + print(e); } } : null, diff --git a/lib/screens/home/worshop_detail/workshop_detail.dart b/lib/screens/home/worshop_detail/workshop_detail.dart index f199508c..b96f02ff 100644 --- a/lib/screens/home/worshop_detail/workshop_detail.dart +++ b/lib/screens/home/worshop_detail/workshop_detail.dart @@ -22,7 +22,8 @@ import 'workshop_detail_widgets.dart'; class WorkshopDetailPage extends StatefulWidget { BuiltWorkshopSummaryPost workshop; final bool isPast; - WorkshopDetailPage({Key key, this.workshop, this.isPast = false}) : super(key: key); + WorkshopDetailPage({Key key, this.workshop, this.isPast = false}) + : super(key: key); @override _WorkshopDetailPage createState() => _WorkshopDetailPage(); } @@ -94,7 +95,8 @@ class _WorkshopDetailPage extends State { onTap: () { setColorPalleteOff(); _bodyBg = true; - _colorListener.value = ColorConstants.workshopContainerBackground; + _colorListener.value = + ColorConstants.workshopContainerBackground; return _colorPicker.getColorPickerDialogBox(context); }, child: Text('body bg'), @@ -210,15 +212,15 @@ class _WorkshopDetailPage extends State { // ..tags = _workshop.tags ); - print(widget.workshop.toString()); + // print(widget.workshop.toString()); if (!this.mounted) return; setState(() {}); } void deleteWorkshop() async { - bool isConfirmed = - await CreatePageDialogBoxes.confirmDialog(context: context, action: 'Delete'); + bool isConfirmed = await CreatePageDialogBoxes.confirmDialog( + context: context, action: 'Delete'); if (isConfirmed == true) { AppConstants.service .removeWorkshop(widget.workshop.id, AppConstants.djangoToken) @@ -250,8 +252,8 @@ class _WorkshopDetailPage extends State { FirebaseMessaging().unsubscribeFromTopic('W_${_workshop.id}'); } - _workshop - .rebuild((b) => b..interested_users = _workshop.interested_users + _newInterestedUser); + _workshop.rebuild((b) => b + ..interested_users = _workshop.interested_users + _newInterestedUser); } }).catchError((onError) { print("Error in toggleing: ${onError.toString()}"); @@ -261,12 +263,13 @@ class _WorkshopDetailPage extends State { } Container _getBackground() { - final File clubLogoFile = - AppConstants.getImageFile(isSmall: true, id: widget.workshop.club.id, isClub: true); + final File clubLogoFile = AppConstants.getImageFile( + isSmall: true, id: widget.workshop.club.id, isClub: true); return Container( child: clubLogoFile == null - ? Image.network(widget.workshop.club.small_image_url, fit: BoxFit.cover, height: 300.0) + ? Image.network(widget.workshop.club.small_image_url, + fit: BoxFit.cover, height: 300.0) : Image.file(clubLogoFile, fit: BoxFit.cover, height: 300), constraints: BoxConstraints.expand(height: 295.0), ); @@ -302,24 +305,30 @@ class _WorkshopDetailPage extends State { widget.isPast ? Container() : is_interested == 0 - ? Container(child: loadingAnimation(), height: 20, width: 20) + ? Container( + child: loadingAnimation(), + height: 20, + width: 20) : InkWell( onTap: () async { if (AppConstants.isGuest) { - _scaffoldKey.currentState.showSnackBar(SnackBar( + _scaffoldKey.currentState + .showSnackBar(SnackBar( content: Text('Please Log In first'), duration: Duration(seconds: 2), )); } else { if (is_interested != 1) { bool shouldCalendarBeOpened = - await CreatePageDialogBoxes.confirmCalendarOpenDialog( - context: context); + await CreatePageDialogBoxes + .confirmCalendarOpenDialog( + context: context); if (shouldCalendarBeOpened == true) { final String _calendarUrl = AppConstants.addEventToCalendarLink( workshop: _workshop); - print('add event to calendar URL: $_calendarUrl'); + print( + 'add event to calendar URL: $_calendarUrl'); launch(_calendarUrl); } } @@ -327,7 +336,8 @@ class _WorkshopDetailPage extends State { } }, child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, children: [ Icon(Icons.star, color: is_interested == 1 @@ -354,6 +364,31 @@ class _WorkshopDetailPage extends State { ); } + Row _getLocationOnMaps() { + return Row( + children: [ + Text('Open In Maps: ', + style: TextStyle( + fontFamily: 'Opensans', + fontSize: 15.0, + color: Colors.white, + fontWeight: FontWeight.w600)), + SizedBox(width: 20), + RaisedButton( + child: Icon(Icons.map), + onPressed: () { + print('lol'); + Navigator.of(context).pushNamed('/mapScreen', arguments: { + 'fromWorkshopDetails': true, + 'latitude': _workshop?.latitude, + 'longitude': _workshop?.longitude, + }); + }, + ), + ], + ); + } + Container _getContent() { final _overviewTitle = "Description".toUpperCase(); return Container( @@ -376,6 +411,11 @@ class _WorkshopDetailPage extends State { ? loadingAnimation() : Text(_workshop.description, style: Style.commonTextStyle), _getPeopleGoing(), + Separator(), + (_workshop?.latitude ?? null) != null && + (_workshop?.longitude ?? null) != null + ? _getLocationOnMaps() + : Container(), ], ), ), @@ -395,7 +435,8 @@ class _WorkshopDetailPage extends State { children: [ Text( 'Edit', - style: TextStyle(color: Colors.yellow, fontWeight: FontWeight.bold), + style: TextStyle( + color: Colors.yellow, fontWeight: FontWeight.bold), ), IconButton( icon: Icon( @@ -422,7 +463,8 @@ class _WorkshopDetailPage extends State { children: [ Text( 'Delete', - style: TextStyle(color: Colors.red, fontWeight: FontWeight.bold), + style: + TextStyle(color: Colors.red, fontWeight: FontWeight.bold), ), IconButton( iconSize: 50, @@ -442,7 +484,8 @@ class _WorkshopDetailPage extends State { height: MediaQuery.of(context).size.height * 0.75, decoration: BoxDecoration( borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(35.0), bottomRight: Radius.circular(35.0)), + bottomLeft: Radius.circular(35.0), + bottomRight: Radius.circular(35.0)), color: ColorConstants.workshopContainerBackground, ), ), @@ -469,7 +512,8 @@ class _WorkshopDetailPage extends State { child: ListView( controller: sc, children: [ - WorkshopDetailWidgets.getHeading(icon: Icons.location_on, title: 'Location'), + WorkshopDetailWidgets.getHeading( + icon: Icons.location_on, title: 'Location'), SizedBox(height: 5.0), _workshop == null ? Container( @@ -482,13 +526,21 @@ class _WorkshopDetailPage extends State { //style: baseTextStyle, ), SizedBox(height: 5.0), - Text( - //'${_workshop.longitude}', - '(Lattitude,Longitude)', - //style: baseTextStyle, + Row( + children: [ + Text( + //'${_workshop.longitude}', + (_workshop?.latitude ?? null) != null && + (_workshop?.longitude ?? null) != null + ? '(${_workshop?.latitude}, ${_workshop?.longitude})' + : '(Lattitude,Longitude)', + //style: baseTextStyle, + ), + ], ), SizedBox(height: 15.0), - WorkshopDetailWidgets.getHeading(icon: Icons.library_books, title: 'Resouces'), + WorkshopDetailWidgets.getHeading( + icon: Icons.library_books, title: 'Resouces'), SizedBox(height: 5.0), _workshop == null ? Container( @@ -500,7 +552,8 @@ class _WorkshopDetailPage extends State { 'No Resources', ), SizedBox(height: 15.0), - WorkshopDetailWidgets.getHeading(icon: Icons.people, title: 'Audience'), + WorkshopDetailWidgets.getHeading( + icon: Icons.people, title: 'Audience'), SizedBox(height: 5.0), _workshop == null ? Container( @@ -512,7 +565,8 @@ class _WorkshopDetailPage extends State { //'No Audience', ), SizedBox(height: 15.0), - WorkshopDetailWidgets.getHeading(icon: Icons.contacts, title: 'Contacts'), + WorkshopDetailWidgets.getHeading( + icon: Icons.contacts, title: 'Contacts'), SizedBox(height: 5.0), _workshop == null ? Container( diff --git a/lib/screens/map.dart b/lib/screens/map.dart index 949ada80..400de57d 100644 --- a/lib/screens/map.dart +++ b/lib/screens/map.dart @@ -1,21 +1,41 @@ import 'dart:async'; import 'dart:math'; -import 'package:carousel_slider/carousel_slider.dart'; import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:iit_app/screens/drawer.dart'; // TODO: in androidManifest.xml , api key has to be changed (register on goole cloud platform from original gmail and generate api key and enable required services) +int timesCalled = 0; + class MapScreen extends StatelessWidget { + bool _fromCreateWorkshop = false; + bool _fromWorkshopDetails = false; + String _workshopLatitude = ''; + String _workshopLongitude = ''; @override Widget build(BuildContext context) { + final Map arguments = ModalRoute.of(context).settings.arguments as Map; + if (arguments != null) { + _fromCreateWorkshop = arguments['fromWorkshopCreate'] ?? false; + _fromWorkshopDetails = arguments['fromWorkshopDetails'] ?? false; + if (_fromWorkshopDetails) { + _workshopLatitude = arguments['latitude']; + _workshopLongitude = arguments['longitude']; + } + } + return SafeArea( minimum: const EdgeInsets.all(2.0), child: Scaffold( drawer: SideBar(context: context), - body: LocationScreen(), + body: LocationScreen( + _fromCreateWorkshop, + _fromWorkshopDetails, + _workshopLatitude, + _workshopLongitude, + ), ), ); } @@ -23,6 +43,18 @@ class MapScreen extends StatelessWidget { class LocationScreen extends StatefulWidget { final Key _mapKey = UniqueKey(); + final bool fromCreateWorkshop; + final bool fromWorkshopDetails; + final String workshopLatitude; + final String workshopLongitude; + + LocationScreen( + this.fromCreateWorkshop, + this.fromWorkshopDetails, + this.workshopLatitude, + this.workshopLongitude, + ) : super(); + @override _LocationScreenState createState() => _LocationScreenState(); } @@ -30,13 +62,30 @@ class LocationScreen extends StatefulWidget { class _LocationScreenState extends State { @override Widget build(BuildContext context) { - return TheMap(key: widget._mapKey); + return TheMap( + key: widget._mapKey, + fromCreateWorkshop: widget.fromCreateWorkshop, + fromWorkshopDetails: widget.fromWorkshopDetails, + workshopLatitude: widget.workshopLatitude, + workshopLongitude: widget.workshopLongitude, + ); } } class TheMap extends StatefulWidget { + final bool fromCreateWorkshop; + final bool fromWorkshopDetails; + final String workshopLatitude; + final String workshopLongitude; + ///key is required, otherwise map crashes on hot reload - TheMap({@required Key key}) : super(key: key); + TheMap({ + @required Key key, + this.fromCreateWorkshop, + this.fromWorkshopDetails, + this.workshopLatitude, + this.workshopLongitude, + }) : super(key: key); @override _MyAppState createState() => _MyAppState(); @@ -55,12 +104,23 @@ class _MyAppState extends State { bool _selectedList = false; - final CameraPosition _initialCameraPosition = CameraPosition( - target: LatLng(25.267878, 82.990494), - zoom: 15, - bearing: 0.0, - tilt: 0.0, - ); + CameraPosition _initialCameraPosition( + [String workshopLatitude = '', String workshopLongitude = '']) { + print(workshopLatitude); + return workshopLatitude == '' + ? CameraPosition( + target: LatLng(25.267878, 82.990494), + zoom: 15, + bearing: 0.0, + tilt: 0.0, + ) + : CameraPosition( + target: LatLng(double.parse(workshopLatitude), + double.parse(workshopLongitude)), + zoom: 18, + tilt: 75, + bearing: Random().nextDouble() * 90); + } moveCameraToMarker(Map coord) async { final GoogleMapController controller = await mapController.future; @@ -75,6 +135,20 @@ class _MyAppState extends State { ); } + simpleMoveCameraToMarker(String latitude, String longitude) async { + print('Going to ($latitude, $longitude)'); + final GoogleMapController controller = await mapController.future; + final _camera = CameraPosition( + target: LatLng(double.parse(latitude), double.parse(longitude)), + zoom: 18, + tilt: 75, + bearing: Random().nextDouble() * 90, + ); + controller.animateCamera( + CameraUpdate.newCameraPosition(_camera), + ); + } + Marker _getMarker({String category, var coord, int i, double hue}) { return Marker( icon: BitmapDescriptor.defaultMarkerWithHue(hue), @@ -136,9 +210,14 @@ class _MyAppState extends State { } _displayMarkers.addAll(_allMarkers); - setState(() { - print(_displayMarkers.length); - }); + if (mounted) + setState(() { + print(_displayMarkers.length); + if (widget.fromCreateWorkshop && timesCalled == 0) { + _settingModalBottomSheet(context); + timesCalled += 1; + } + }); } void _settingModalBottomSheet(context) { @@ -161,11 +240,12 @@ class _MyAppState extends State { child: InkWell( splashColor: Colors.brown, onTap: () { - setState(() { - _selectedList = true; + if (this.mounted) + setState(() { + _selectedList = true; - _displayMarkers = _hostelMarkers; - }); + _displayMarkers = _hostelMarkers; + }); }, child: Text( 'Hostels', @@ -182,11 +262,12 @@ class _MyAppState extends State { ), child: InkWell( onTap: () { - setState(() { - _selectedList = true; + if (this.mounted) + setState(() { + _selectedList = true; - _displayMarkers = _departmentMarkers; - }); + _displayMarkers = _departmentMarkers; + }); }, child: Text( 'Departments', @@ -196,11 +277,12 @@ class _MyAppState extends State { ), InkWell( onTap: () { - setState(() { - _selectedList = true; + if (this.mounted) + setState(() { + _selectedList = true; - _displayMarkers = _lectureHallMarkers; - }); + _displayMarkers = _lectureHallMarkers; + }); }, child: Container( margin: EdgeInsets.all(3), @@ -217,10 +299,11 @@ class _MyAppState extends State { ), InkWell( onTap: () { - setState(() { - _displayMarkers = _otherMarkers; - _selectedList = true; - }); + if (this.mounted) + setState(() { + _displayMarkers = _otherMarkers; + _selectedList = true; + }); }, child: Container( margin: EdgeInsets.all(3), @@ -242,127 +325,201 @@ class _MyAppState extends State { ); } + static Future locationSetDialog( + BuildContext context, String title, String innerText) async { + return showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text(title ?? '(No Title)'), + content: Text(innerText ?? '(No Inner Text)'), + actions: [ + FlatButton( + child: Text("Yup!"), + onPressed: () { + Navigator.of(context).pop(true); + }, + ), + FlatButton( + child: Text("Nope!"), + onPressed: () { + Navigator.of(context).pop(false); + return false; + }, + ), + ], + ); + }); + } + + @override + void initState() { + super.initState(); + } + @override void dispose() { super.dispose(); + timesCalled = 0; } @override - Widget build(BuildContext context) => Scaffold( - appBar: AppBar( - title: Text('Google Maps (under dev)'), - centerTitle: true, - leading: IconButton( - icon: Icon(Icons.arrow_back, color: Colors.white), - onPressed: () => Navigator.pop(context), - ), - ), - floatingActionButton: FloatingActionButton( - onPressed: () { - _settingModalBottomSheet(context); - }, - child: Icon(Icons.add), + Widget build(BuildContext context) { + // if (widget.fromCreateWorkshop && timesCalled == 0) + // WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + // _settingModalBottomSheet(context); + // print('timesCalled: $timesCalled'); + // timesCalled += 1; + // }); + // if (widget.fromWorkshopDetails) { + // WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + // simpleMoveCameraToMarker( + // widget.workshopLatitude, widget.workshopLongitude); + // }); + // } + return Scaffold( + appBar: AppBar( + title: Text((widget.fromCreateWorkshop ? 'Workshop Location-' : '') + + 'Google Maps (under dev)'), + centerTitle: true, + leading: IconButton( + icon: Icon(Icons.arrow_back, color: Colors.white), + onPressed: () => Navigator.pop(context), ), - floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, - body: Stack( - children: [ - GoogleMap( - onMapCreated: _onMapCreated, - initialCameraPosition: _initialCameraPosition, - mapType: MapType.terrain, - mapToolbarEnabled: true, - markers: Set.from(_displayMarkers), - onTap: (tappedPosition) { - print( - 'lattitude : ${tappedPosition.latitude} longitude: ${tappedPosition.longitude}'); - }, - ), - _selectedList - ? Positioned( - right: 5, - top: 5, - child: InkWell( - onTap: () async { - setState(() { - _selectedList = false; - _displayMarkers = _allMarkers; - }); - - final GoogleMapController controller = - await mapController.future; - controller.animateCamera(CameraUpdate.newCameraPosition( - _initialCameraPosition)); - }, - child: Container( - padding: EdgeInsets.all(10), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(50), - color: Colors.black), - child: Text( - 'Clear X', - style: TextStyle(color: Colors.white), - ), - ), - ), - ) - : Container(), - _selectedList - ? Positioned( - top: 50, - left: 25, + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + _settingModalBottomSheet(context); + }, + child: Icon(Icons.add), + ), + floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, + body: Stack( + children: [ + GoogleMap( + onMapCreated: _onMapCreated, + initialCameraPosition: widget.fromWorkshopDetails + ? _initialCameraPosition( + widget.workshopLatitude, widget.workshopLongitude) + : _initialCameraPosition(), + mapType: MapType.terrain, + mapToolbarEnabled: true, + markers: Set.from(_displayMarkers), + onTap: (tappedPosition) { + print( + 'lattitude : ${tappedPosition.latitude} longitude: ${tappedPosition.longitude}'); + }, + ), + _selectedList + ? Positioned( + right: 5, + top: 5, + child: InkWell( + onTap: () async { + setState(() { + _selectedList = false; + _displayMarkers = _allMarkers; + }); + + final GoogleMapController controller = + await mapController.future; + controller.animateCamera(CameraUpdate.newCameraPosition( + _initialCameraPosition())); + }, child: Container( + padding: EdgeInsets.all(10), decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.black12, - boxShadow: [ - BoxShadow( - color: Colors.black54, - blurRadius: 3, - spreadRadius: 5, - ), - ], + borderRadius: BorderRadius.circular(50), + color: Colors.black), + child: Text( + 'Clear X', + style: TextStyle(color: Colors.white), ), - height: 50, - width: MediaQuery.of(context).size.width - 50, - child: ListView.builder( - scrollDirection: Axis.horizontal, - itemCount: _displayMarkers.length, - itemBuilder: (context, index) { - Marker _tappableMarker = _displayMarkers[index]; - return InkWell( - onTap: () async { - final GoogleMapController controller = - await mapController.future; - controller.animateCamera( - CameraUpdate.newCameraPosition( - CameraPosition( - target: _tappableMarker.position, - zoom: 18, - tilt: 75.0, - bearing: Random().nextDouble() * 90, - ), + ), + ), + ) + : Container(), + _selectedList + ? Positioned( + top: 50, + left: 25, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.black12, + boxShadow: [ + BoxShadow( + color: Colors.black54, + blurRadius: 3, + spreadRadius: 5, + ), + ], + ), + height: 50, + width: MediaQuery.of(context).size.width - 50, + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: _displayMarkers.length, + itemBuilder: (context, index) { + Marker _tappableMarker = _displayMarkers[index]; + return InkWell( + onTap: () async { + final GoogleMapController controller = + await mapController.future; + controller.animateCamera( + CameraUpdate.newCameraPosition( + CameraPosition( + target: _tappableMarker.position, + zoom: 18, + tilt: 75.0, + bearing: Random().nextDouble() * 90, ), - ); - }, - child: Container( - margin: EdgeInsets.all(5), - padding: EdgeInsets.all(10), - decoration: BoxDecoration( - color: Colors.blue, - borderRadius: BorderRadius.circular(10), ), - child: Text(_tappableMarker.infoWindow.title, - style: TextStyle(color: Colors.white)), + ); + if (widget.fromCreateWorkshop) { + print(_displayMarkers[index]); + bool shouldLocationbeSet = await locationSetDialog( + context, + 'Location Set', + 'Do you want to set ${_displayMarkers[index].infoWindow.title} as the location for the workshop?'); + if (shouldLocationbeSet) { + Navigator.pop(context, [ + _displayMarkers[index] + .position + .latitude + .toString(), + _displayMarkers[index] + .position + .longitude + .toString(), + _displayMarkers[index] + .infoWindow + .title + .toString(), + ]); + } + } + }, + child: Container( + margin: EdgeInsets.all(5), + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.blue, + borderRadius: BorderRadius.circular(10), ), - ); - }, - ), + child: Text(_tappableMarker.infoWindow.title, + style: TextStyle(color: Colors.white)), + ), + ); + }, ), - ) - : Container(), - ], - ), - ); + ), + ) + : Container(), + ], + ), + ); + } } Map coords = {