Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ analyzer:
errors:
missing_required_param: error
missing_return: error
exclude:
- build/**

linter:
rules:
Expand Down
8 changes: 4 additions & 4 deletions example/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ migration:
create_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
base_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
- platform: android
create_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
base_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
create_revision: 87af191112a7455b061449b773b2bff92ccdbcd0
base_revision: 87af191112a7455b061449b773b2bff92ccdbcd0
- platform: ios
create_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
base_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
Expand All @@ -35,5 +35,5 @@ migration:
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
- "lib/main.dart"
- "ios/Runner.xcodeproj/project.pbxproj"
9 changes: 9 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
analyzer:
exclude:
- build/**
- android/**
- ios/**
- web/**
- windows/**
- macos/**

# match the lint rules from flutter_map
include: ./../analysis_options.yaml

Expand Down
2 changes: 1 addition & 1 deletion example/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ android {

flutter {
source = "../.."
}
}
5 changes: 4 additions & 1 deletion example/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ allprojects {
}
}

val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get()
val newBuildDir: Directory =
rootProject.layout.buildDirectory
.dir("../../build")
.get()
rootProject.layout.buildDirectory.value(newBuildDir)

subprojects {
Expand Down
2 changes: 2 additions & 0 deletions example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.newDsl=false
android.builtInKotlin=false
15 changes: 8 additions & 7 deletions example/android/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
pluginManagement {
val flutterSdkPath = run {
val properties = java.util.Properties()
file("local.properties").inputStream().use { properties.load(it) }
val flutterSdkPath = properties.getProperty("flutter.sdk")
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
flutterSdkPath
}
val flutterSdkPath =
run {
val properties = java.util.Properties()
file("local.properties").inputStream().use { properties.load(it) }
val flutterSdkPath = properties.getProperty("flutter.sdk")
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
flutterSdkPath
}

includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

Expand Down
41 changes: 34 additions & 7 deletions example/lib/misc/tile_providers.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,40 @@
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:http/http.dart';
import 'package:http/retry.dart';
import 'package:url_launcher/url_launcher.dart';

final httpClient = RetryClient(Client());
final _httpClient = RetryClient(Client());

// TODO: This causes unneccessary rebuilding
TileLayer get openStreetMapTileLayer => TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: 'dev.fleaflet.flutter_map.demo',
tileProvider: NetworkTileProvider(httpClient: httpClient),
maxNativeZoom: 19,
class PrimaryTileLayer extends StatelessWidget {
const PrimaryTileLayer({super.key, this.showAttributionImmediately = false});

final bool showAttributionImmediately;

@override
Widget build(BuildContext context) {
return Stack(
children: [
TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: 'dev.fleaflet.flutter_map.demo',
tileProvider: NetworkTileProvider(httpClient: _httpClient),
maxNativeZoom: 19,
),
RichAttributionWidget(
popupInitialDisplayDuration: showAttributionImmediately
? const Duration(seconds: 5)
: Duration.zero,
animationConfig: const ScaleRAWA(),
attributions: [
TextSourceAttribution(
'OpenStreetMap contributors',
onTap: () async =>
launchUrl(Uri.parse('https://openstreetmap.org/copyright')),
),
],
),
],
);
}
}
2 changes: 1 addition & 1 deletion example/lib/pages/circle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class _CirclePageState extends State<CirclePage> {
initialZoom: 11,
),
children: [
openStreetMapTileLayer,
const PrimaryTileLayer(),
MouseRegion(
hitTestBehavior: HitTestBehavior.deferToChild,
cursor: SystemMouseCursors.click,
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/fling_animation_damping.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class _FlingAnimationDampingPageState extends State<FlingAnimationDampingPage> {
),
),
children: [
openStreetMapTileLayer,
const PrimaryTileLayer(),
Center(
child: Container(
padding: const EdgeInsets.all(8),
Expand Down
59 changes: 5 additions & 54 deletions example/lib/pages/home.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_map_example/misc/tile_providers.dart';
import 'package:flutter_map_example/widgets/drawer/floating_menu_button.dart';
import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart';
import 'package:flutter_map_example/widgets/first_start_dialog.dart';
import 'package:latlong2/latlong.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:url_launcher/url_launcher.dart';

class HomePage extends StatefulWidget {
static const String route = '/';
Expand All @@ -20,69 +15,25 @@ class HomePage extends StatefulWidget {
}

class _HomePageState extends State<HomePage> {
@override
void initState() {
super.initState();
showIntroDialogIfNeeded();
}

@override
Widget build(BuildContext context) {
return Scaffold(
drawer: const MenuDrawer(HomePage.route),
return const Scaffold(
drawer: MenuDrawer(HomePage.route),
body: Stack(
children: [
FlutterMap(
options: const MapOptions(
options: MapOptions(
initialCenter: LatLng(51.5, -0.09),
initialZoom: 5,
maxZoom: 21,
),
children: [
openStreetMapTileLayer,
RichAttributionWidget(
popupInitialDisplayDuration: const Duration(seconds: 5),
animationConfig: const ScaleRAWA(),
showFlutterMapAttribution: false,
attributions: [
TextSourceAttribution(
'OpenStreetMap contributors',
onTap: () async => launchUrl(
Uri.parse('https://openstreetmap.org/copyright'),
),
),
const TextSourceAttribution(
'This attribution is the same throughout this app, except '
'where otherwise specified',
prependCopyright: false,
),
],
),
PrimaryTileLayer(showAttributionImmediately: true),
],
),
const FloatingMenuButton()
FloatingMenuButton(),
],
),
);
}

void showIntroDialogIfNeeded() {
const seenIntroBoxKey = 'seenIntroBox(a)';
if (kIsWeb && Uri.base.host.trim() == 'demo.fleaflet.dev') {
SchedulerBinding.instance.addPostFrameCallback(
(_) async {
final prefs = await SharedPreferences.getInstance();
if (prefs.getBool(seenIntroBoxKey) ?? false) return;

if (!mounted) return;

await showDialog<void>(
context: context,
builder: (context) => const FirstStartDialog(),
);
await prefs.setBool(seenIntroBoxKey, true);
},
);
}
}
}
2 changes: 1 addition & 1 deletion example/lib/pages/interactive_test_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class _InteractiveFlagsPageState extends State<InteractiveFlagsPage> {
),
children: [child!],
),
child: openStreetMapTileLayer,
child: const PrimaryTileLayer(),
),
),
],
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/latlng_to_screen_point.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class _LatLngToScreenPointPageState extends State<LatLngToScreenPointPage> {
},
),
children: [
openStreetMapTileLayer,
const PrimaryTileLayer(),
if (tappedCoords != null)
MarkerLayer(
markers: [
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/many_circles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class _ManyCirclesPageState extends State<ManyCirclesPage> {
),
),
children: [
openStreetMapTileLayer,
const PrimaryTileLayer(),
CircleLayer(
circles: allCircles
.take(displayedCirclesCount)
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/many_markers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class ManyMarkersPageState extends State<ManyMarkersPage> {
),
),
children: [
openStreetMapTileLayer,
const PrimaryTileLayer(),
MarkerLayer(
markers: allMarkers
.take(displayedMarkersCount)
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/map_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class MapControllerPageState extends State<MapControllerPage> {
minZoom: 3,
),
children: [
openStreetMapTileLayer,
const PrimaryTileLayer(),
const MarkerLayer(markers: _markers),
],
),
Expand Down
8 changes: 4 additions & 4 deletions example/lib/pages/map_inside_listview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ class MapInsideListViewPage extends StatelessWidget {
child: ListView(
scrollDirection: Axis.vertical,
children: [
SizedBox(
const SizedBox(
height: 300,
child: FlutterMap(
options: const MapOptions(
options: MapOptions(
initialCenter: LatLng(51.5, -0.09),
initialZoom: 5,
),
children: [
openStreetMapTileLayer,
const FlutterMapZoomButtons(
PrimaryTileLayer(),
FlutterMapZoomButtons(
minZoom: 4,
maxZoom: 19,
mini: true,
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/markers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class _MarkerPageState extends State<MarkerPage> {
),
),
children: [
openStreetMapTileLayer,
const PrimaryTileLayer(),
MarkerLayer(
rotate: counterRotate,
markers: [
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/overlay_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class OverlayImagePage extends StatelessWidget {
initialZoom: 6,
),
children: [
openStreetMapTileLayer,
const PrimaryTileLayer(),
OverlayImageLayer(
overlayImages: [
OverlayImage(
Expand Down
8 changes: 4 additions & 4 deletions example/lib/pages/plugin_zoombuttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ class PluginZoomButtons extends StatelessWidget {
return Scaffold(
appBar: AppBar(title: const Text('Zoom Buttons Plugin')),
drawer: const MenuDrawer(PluginZoomButtons.route),
body: FlutterMap(
options: const MapOptions(
body: const FlutterMap(
options: MapOptions(
initialCenter: LatLng(51.5, -0.09),
initialZoom: 5,
),
children: [
openStreetMapTileLayer,
const FlutterMapZoomButtons(
PrimaryTileLayer(),
FlutterMapZoomButtons(
minZoom: 4,
maxZoom: 19,
mini: true,
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/polygon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class _PolygonPageState extends State<PolygonPage> {
initialZoom: 4,
),
children: [
openStreetMapTileLayer,
const PrimaryTileLayer(),
MouseRegion(
hitTestBehavior: HitTestBehavior.deferToChild,
cursor: SystemMouseCursors.click,
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/polygon_perf_stress.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class _PolygonPerfStressPageState extends State<PolygonPerfStressPage> {
),
),
children: [
openStreetMapTileLayer,
const PrimaryTileLayer(),
FutureBuilder(
future: polygons,
builder: (context, polygons) => polygons.data == null
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/polyline.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class _PolylinePageState extends State<PolylinePage> {
initialZoom: 5,
),
children: [
openStreetMapTileLayer,
const PrimaryTileLayer(),
MouseRegion(
hitTestBehavior: HitTestBehavior.deferToChild,
cursor: SystemMouseCursors.click,
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/polyline_perf_stress.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class _PolylinePerfStressPageState extends State<PolylinePerfStressPage> {
),
),
children: [
openStreetMapTileLayer,
const PrimaryTileLayer(),
PolylineLayer(
simplificationTolerance: simplificationTolerance,
polylines: [
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/repeated_worlds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class _RepeatedWorldsPageState extends State<RepeatedWorldsPage> {
cameraConstraint: const CameraConstraint.containLatitude(),
),
children: [
openStreetMapTileLayer,
const PrimaryTileLayer(),
GestureDetector(
onTap: () => ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
Expand Down
Loading