Skip to content

Commit 34457c1

Browse files
authored
chore(example): prepare for upgrade to built-in Kotlin (#2252)
1 parent 638554b commit 34457c1

35 files changed

Lines changed: 364 additions & 355 deletions

‎analysis_options.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ analyzer:
88
errors:
99
missing_required_param: error
1010
missing_return: error
11+
exclude:
12+
- build/**
1113

1214
linter:
1315
rules:

‎example/.metadata‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ migration:
1616
create_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
1717
base_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
1818
- platform: android
19-
create_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
20-
base_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
19+
create_revision: 87af191112a7455b061449b773b2bff92ccdbcd0
20+
base_revision: 87af191112a7455b061449b773b2bff92ccdbcd0
2121
- platform: ios
2222
create_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
2323
base_revision: b45fa18946ecc2d9b4009952c636ba7e2ffbb787
@@ -35,5 +35,5 @@ migration:
3535
#
3636
# Files that are not part of the templates will be ignored by default.
3737
unmanaged_files:
38-
- 'lib/main.dart'
39-
- 'ios/Runner.xcodeproj/project.pbxproj'
38+
- "lib/main.dart"
39+
- "ios/Runner.xcodeproj/project.pbxproj"

‎example/analysis_options.yaml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
analyzer:
2+
exclude:
3+
- build/**
4+
- android/**
5+
- ios/**
6+
- web/**
7+
- windows/**
8+
- macos/**
9+
110
# match the lint rules from flutter_map
211
include: ./../analysis_options.yaml
312

‎example/android/app/build.gradle.kts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ android {
3636

3737
flutter {
3838
source = "../.."
39-
}
39+
}

‎example/android/build.gradle.kts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ allprojects {
55
}
66
}
77

8-
val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get()
8+
val newBuildDir: Directory =
9+
rootProject.layout.buildDirectory
10+
.dir("../../build")
11+
.get()
912
rootProject.layout.buildDirectory.value(newBuildDir)
1013

1114
subprojects {

‎example/android/gradle.properties‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
22
android.useAndroidX=true
3+
android.newDsl=false
4+
android.builtInKotlin=false

‎example/android/settings.gradle.kts‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
pluginManagement {
2-
val flutterSdkPath = run {
3-
val properties = java.util.Properties()
4-
file("local.properties").inputStream().use { properties.load(it) }
5-
val flutterSdkPath = properties.getProperty("flutter.sdk")
6-
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
7-
flutterSdkPath
8-
}
2+
val flutterSdkPath =
3+
run {
4+
val properties = java.util.Properties()
5+
file("local.properties").inputStream().use { properties.load(it) }
6+
val flutterSdkPath = properties.getProperty("flutter.sdk")
7+
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
8+
flutterSdkPath
9+
}
910

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

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,40 @@
1+
import 'package:flutter/material.dart';
12
import 'package:flutter_map/flutter_map.dart';
23
import 'package:http/http.dart';
34
import 'package:http/retry.dart';
5+
import 'package:url_launcher/url_launcher.dart';
46

5-
final httpClient = RetryClient(Client());
7+
final _httpClient = RetryClient(Client());
68

7-
// TODO: This causes unneccessary rebuilding
8-
TileLayer get openStreetMapTileLayer => TileLayer(
9-
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
10-
userAgentPackageName: 'dev.fleaflet.flutter_map.demo',
11-
tileProvider: NetworkTileProvider(httpClient: httpClient),
12-
maxNativeZoom: 19,
9+
class PrimaryTileLayer extends StatelessWidget {
10+
const PrimaryTileLayer({super.key, this.showAttributionImmediately = false});
11+
12+
final bool showAttributionImmediately;
13+
14+
@override
15+
Widget build(BuildContext context) {
16+
return Stack(
17+
children: [
18+
TileLayer(
19+
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
20+
userAgentPackageName: 'dev.fleaflet.flutter_map.demo',
21+
tileProvider: NetworkTileProvider(httpClient: _httpClient),
22+
maxNativeZoom: 19,
23+
),
24+
RichAttributionWidget(
25+
popupInitialDisplayDuration: showAttributionImmediately
26+
? const Duration(seconds: 5)
27+
: Duration.zero,
28+
animationConfig: const ScaleRAWA(),
29+
attributions: [
30+
TextSourceAttribution(
31+
'OpenStreetMap contributors',
32+
onTap: () async =>
33+
launchUrl(Uri.parse('https://openstreetmap.org/copyright')),
34+
),
35+
],
36+
),
37+
],
1338
);
39+
}
40+
}

‎example/lib/pages/circle.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class _CirclePageState extends State<CirclePage> {
7575
initialZoom: 11,
7676
),
7777
children: [
78-
openStreetMapTileLayer,
78+
const PrimaryTileLayer(),
7979
MouseRegion(
8080
hitTestBehavior: HitTestBehavior.deferToChild,
8181
cursor: SystemMouseCursors.click,

‎example/lib/pages/fling_animation_damping.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class _FlingAnimationDampingPageState extends State<FlingAnimationDampingPage> {
105105
),
106106
),
107107
children: [
108-
openStreetMapTileLayer,
108+
const PrimaryTileLayer(),
109109
Center(
110110
child: Container(
111111
padding: const EdgeInsets.all(8),

0 commit comments

Comments
 (0)