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:
3
place_tracker/.gitignore
vendored
3
place_tracker/.gitignore
vendored
@@ -69,3 +69,6 @@
|
|||||||
!**/ios/**/default.pbxuser
|
!**/ios/**/default.pbxuser
|
||||||
!**/ios/**/default.perspectivev3
|
!**/ios/**/default.perspectivev3
|
||||||
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
|
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
|
||||||
|
|
||||||
|
# Flutter Web files
|
||||||
|
lib/generated_plugin_registrant.dart
|
||||||
|
|||||||
@@ -61,6 +61,13 @@ Specify your API key in `AppDelegate.swift`:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Web
|
||||||
|
Add your API key to `web/index.html` in the `<head>` tag:
|
||||||
|
|
||||||
|
```
|
||||||
|
<script src="https://maps.googleapis.com/maps/api/js?key=<YOUR_API_KEY_HERE>"></script>
|
||||||
|
```
|
||||||
|
|
||||||
For additional help setting up the plugin, see the plugin's
|
For additional help setting up the plugin, see the plugin's
|
||||||
[README](https://pub.dev/packages/google_maps_flutter)
|
[README](https://pub.dev/packages/google_maps_flutter)
|
||||||
page.
|
page.
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class MapConfiguration {
|
|||||||
final List<Place> places;
|
final List<Place> places;
|
||||||
|
|
||||||
final PlaceCategory selectedCategory;
|
final PlaceCategory selectedCategory;
|
||||||
|
|
||||||
const MapConfiguration({
|
const MapConfiguration({
|
||||||
@required this.places,
|
@required this.places,
|
||||||
@required this.selectedCategory,
|
@required this.selectedCategory,
|
||||||
@@ -133,7 +134,21 @@ class PlaceMapState extends State<PlaceMap> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Zoom to fit the initially selected category.
|
// 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(
|
_getPlacesForCategory(
|
||||||
Provider.of<AppState>(context, listen: false).selectedCategory,
|
Provider.of<AppState>(context, listen: false).selectedCategory,
|
||||||
_markedPlaces.values.toList(),
|
_markedPlaces.values.toList(),
|
||||||
@@ -414,11 +429,13 @@ class PlaceMapState extends State<PlaceMap> {
|
|||||||
switch (category) {
|
switch (category) {
|
||||||
case PlaceCategory.favorite:
|
case PlaceCategory.favorite:
|
||||||
return BitmapDescriptor.fromAssetImage(
|
return BitmapDescriptor.fromAssetImage(
|
||||||
createLocalImageConfiguration(context), 'assets/heart.png');
|
createLocalImageConfiguration(context, size: Size.square(32)),
|
||||||
|
'assets/heart.png');
|
||||||
break;
|
break;
|
||||||
case PlaceCategory.visited:
|
case PlaceCategory.visited:
|
||||||
return BitmapDescriptor.fromAssetImage(
|
return BitmapDescriptor.fromAssetImage(
|
||||||
createLocalImageConfiguration(context), 'assets/visited.png');
|
createLocalImageConfiguration(context, size: Size.square(32)),
|
||||||
|
'assets/visited.png');
|
||||||
break;
|
break;
|
||||||
case PlaceCategory.wantToGo:
|
case PlaceCategory.wantToGo:
|
||||||
default:
|
default:
|
||||||
@@ -437,6 +454,7 @@ class _AddPlaceButtonBar extends StatelessWidget {
|
|||||||
|
|
||||||
final VoidCallback onSavePressed;
|
final VoidCallback onSavePressed;
|
||||||
final VoidCallback onCancelPressed;
|
final VoidCallback onCancelPressed;
|
||||||
|
|
||||||
const _AddPlaceButtonBar({
|
const _AddPlaceButtonBar({
|
||||||
Key key,
|
Key key,
|
||||||
@required this.visible,
|
@required this.visible,
|
||||||
|
|||||||
@@ -7,42 +7,42 @@ packages:
|
|||||||
name: async
|
name: async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.2"
|
version: "2.5.0-nullsafety"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: boolean_selector
|
name: boolean_selector
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.1.0-nullsafety"
|
||||||
characters:
|
characters:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: characters
|
name: characters
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.0"
|
version: "1.1.0-nullsafety.2"
|
||||||
charcode:
|
charcode:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: charcode
|
name: charcode
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.3"
|
version: "1.2.0-nullsafety"
|
||||||
clock:
|
clock:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: clock
|
name: clock
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.1"
|
version: "1.1.0-nullsafety"
|
||||||
collection:
|
collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: collection
|
name: collection
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.14.13"
|
version: "1.15.0-nullsafety.2"
|
||||||
convert:
|
convert:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -57,6 +57,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.5"
|
version: "2.1.5"
|
||||||
|
csslib:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: csslib
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.16.2"
|
||||||
cupertino_icons:
|
cupertino_icons:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -70,7 +77,7 @@ packages:
|
|||||||
name: fake_async
|
name: fake_async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.1.0-nullsafety"
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -82,19 +89,31 @@ packages:
|
|||||||
name: flutter_plugin_android_lifecycle
|
name: flutter_plugin_android_lifecycle
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.8"
|
version: "1.0.9"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_web_plugins:
|
||||||
|
dependency: transitive
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.0"
|
||||||
|
google_maps:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: google_maps
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.4.5"
|
||||||
google_maps_flutter:
|
google_maps_flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: google_maps_flutter
|
name: google_maps_flutter
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.5.30"
|
version: "0.5.32"
|
||||||
google_maps_flutter_platform_interface:
|
google_maps_flutter_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -102,20 +121,41 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.4"
|
version: "1.0.4"
|
||||||
|
google_maps_flutter_web:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: google_maps_flutter_web
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.1.0+2"
|
||||||
|
html:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: html
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.14.0+3"
|
||||||
|
js_wrapping:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: js_wrapping
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.5.0"
|
||||||
matcher:
|
matcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.8"
|
version: "0.12.10-nullsafety"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.8"
|
version: "1.3.0-nullsafety.2"
|
||||||
nested:
|
nested:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -129,14 +169,14 @@ packages:
|
|||||||
name: path
|
name: path
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.7.0"
|
version: "1.8.0-nullsafety"
|
||||||
pedantic:
|
pedantic:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: pedantic
|
name: pedantic
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.0"
|
version: "1.9.2"
|
||||||
plugin_platform_interface:
|
plugin_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -150,7 +190,14 @@ packages:
|
|||||||
name: provider
|
name: provider
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.3.2"
|
version: "4.3.2+2"
|
||||||
|
sanitize_html:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: sanitize_html
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.3.0"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -162,21 +209,21 @@ packages:
|
|||||||
name: source_span
|
name: source_span
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.7.0"
|
version: "1.8.0-nullsafety"
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stack_trace
|
name: stack_trace
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.5"
|
version: "1.10.0-nullsafety"
|
||||||
stream_channel:
|
stream_channel:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stream_channel
|
name: stream_channel
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.1.0-nullsafety"
|
||||||
stream_transform:
|
stream_transform:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -190,42 +237,42 @@ packages:
|
|||||||
name: string_scanner
|
name: string_scanner
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.5"
|
version: "1.1.0-nullsafety"
|
||||||
term_glyph:
|
term_glyph:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: term_glyph
|
name: term_glyph
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.2.0-nullsafety"
|
||||||
test_api:
|
test_api:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.17"
|
version: "0.2.19-nullsafety"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: typed_data
|
name: typed_data
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.3.0-nullsafety.2"
|
||||||
uuid:
|
uuid:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: uuid
|
name: uuid
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.0"
|
version: "2.2.2"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_math
|
name: vector_math
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.8"
|
version: "2.1.0-nullsafety.2"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.9.0-14.0.dev <3.0.0"
|
dart: ">=2.10.0-0.0.dev <2.10.0"
|
||||||
flutter: ">=1.16.3 <2.0.0"
|
flutter: ">=1.16.3 <2.0.0"
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ dependencies:
|
|||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
cupertino_icons: ^0.1.3
|
cupertino_icons: ^0.1.3
|
||||||
google_maps_flutter: ^0.5.27
|
google_maps_flutter: ^0.5.0
|
||||||
|
google_maps_flutter_web: ^0.1.0
|
||||||
provider: ^4.0.0
|
provider: ^4.0.0
|
||||||
uuid: ^2.0.4
|
uuid: ^2.0.4
|
||||||
|
|
||||||
|
|||||||
BIN
place_tracker/web/favicon.png
Normal file
BIN
place_tracker/web/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 917 B |
BIN
place_tracker/web/icons/Icon-192.png
Normal file
BIN
place_tracker/web/icons/Icon-192.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
BIN
place_tracker/web/icons/Icon-512.png
Normal file
BIN
place_tracker/web/icons/Icon-512.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.1 KiB |
37
place_tracker/web/index.html
Normal file
37
place_tracker/web/index.html
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
|
||||||
|
<meta name="description" content="A new Flutter project.">
|
||||||
|
|
||||||
|
<!-- iOS meta tags & icons -->
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||||
|
<meta name="apple-mobile-web-app-title" content="place_tracker">
|
||||||
|
<link rel="apple-touch-icon" href="icons/Icon-192.png">
|
||||||
|
|
||||||
|
<!-- Favicon -->
|
||||||
|
<link rel="shortcut icon" type="image/png" href="favicon.png"/>
|
||||||
|
|
||||||
|
<!-- // Other stuff -->
|
||||||
|
|
||||||
|
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBEKgpAdjMVMv9IKX-BBsjzwgYMxfZonbw"></script>
|
||||||
|
|
||||||
|
<title>place_tracker</title>
|
||||||
|
<link rel="manifest" href="manifest.json">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!-- This script installs service_worker.js to provide PWA functionality to
|
||||||
|
application. For more information, see:
|
||||||
|
https://developers.google.com/web/fundamentals/primers/service-workers -->
|
||||||
|
<script>
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
window.addEventListener('load', function () {
|
||||||
|
navigator.serviceWorker.register('flutter_service_worker.js');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script src="main.dart.js" type="application/javascript"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
23
place_tracker/web/manifest.json
Normal file
23
place_tracker/web/manifest.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"name": "place_tracker",
|
||||||
|
"short_name": "place_tracker",
|
||||||
|
"start_url": ".",
|
||||||
|
"display": "standalone",
|
||||||
|
"background_color": "#0175C2",
|
||||||
|
"theme_color": "#0175C2",
|
||||||
|
"description": "A new Flutter project.",
|
||||||
|
"orientation": "portrait-primary",
|
||||||
|
"prefer_related_applications": false,
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "icons/Icon-192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "icons/Icon-512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -12,5 +12,6 @@ directories:
|
|||||||
- vision_challenge/web
|
- vision_challenge/web
|
||||||
- form_app/web
|
- form_app/web
|
||||||
- web_dashboard/web
|
- web_dashboard/web
|
||||||
|
- place_tracker/web
|
||||||
|
|
||||||
post-build-dart-script: _tool/peanut_post_build.dart
|
post-build-dart-script: _tool/peanut_post_build.dart
|
||||||
|
|||||||
1
web/place_tracker
Symbolic link
1
web/place_tracker
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../place_tracker
|
||||||
Reference in New Issue
Block a user