mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Add web support to place_tracker (#550)
* enable web for place_tracker * add place_tracker symlink * add generated_plugin_registrant.dart * update google_maps_flutter_web to fix pins not showing * add place_tracker to peanut.yaml * upgrade place_tracker dep * use a 32 pixel square * Apply zoom to selected category when the PlaceMapState updates. This fixes a grey screen issue in web, after saving a place. * pub upgrade * run pub upgrade * use published versions of packages * remove lib/generated_plugin_registrant.dart * add newline * add web API key to README Co-authored-by: David Iglesias Teixeira <ditman@gmail.com>
This commit is contained in:
@@ -15,6 +15,7 @@ class MapConfiguration {
|
||||
final List<Place> places;
|
||||
|
||||
final PlaceCategory selectedCategory;
|
||||
|
||||
const MapConfiguration({
|
||||
@required this.places,
|
||||
@required this.selectedCategory,
|
||||
@@ -133,7 +134,21 @@ class PlaceMapState extends State<PlaceMap> {
|
||||
});
|
||||
|
||||
// Zoom to fit the initially selected category.
|
||||
await _zoomToFitPlaces(
|
||||
_zoomToFitSelectedCategory();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(PlaceMap oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
// Zoom to fit the selected category.
|
||||
if (mounted) {
|
||||
_zoomToFitSelectedCategory();
|
||||
}
|
||||
}
|
||||
|
||||
/// Applies zoom to fit the places of the selected category
|
||||
void _zoomToFitSelectedCategory() {
|
||||
_zoomToFitPlaces(
|
||||
_getPlacesForCategory(
|
||||
Provider.of<AppState>(context, listen: false).selectedCategory,
|
||||
_markedPlaces.values.toList(),
|
||||
@@ -414,11 +429,13 @@ class PlaceMapState extends State<PlaceMap> {
|
||||
switch (category) {
|
||||
case PlaceCategory.favorite:
|
||||
return BitmapDescriptor.fromAssetImage(
|
||||
createLocalImageConfiguration(context), 'assets/heart.png');
|
||||
createLocalImageConfiguration(context, size: Size.square(32)),
|
||||
'assets/heart.png');
|
||||
break;
|
||||
case PlaceCategory.visited:
|
||||
return BitmapDescriptor.fromAssetImage(
|
||||
createLocalImageConfiguration(context), 'assets/visited.png');
|
||||
createLocalImageConfiguration(context, size: Size.square(32)),
|
||||
'assets/visited.png');
|
||||
break;
|
||||
case PlaceCategory.wantToGo:
|
||||
default:
|
||||
@@ -437,6 +454,7 @@ class _AddPlaceButtonBar extends StatelessWidget {
|
||||
|
||||
final VoidCallback onSavePressed;
|
||||
final VoidCallback onCancelPressed;
|
||||
|
||||
const _AddPlaceButtonBar({
|
||||
Key key,
|
||||
@required this.visible,
|
||||
|
||||
Reference in New Issue
Block a user