Skip to content

Commit 5b6131e

Browse files
committed
Update google-maps-in-flutter
1 parent 7ae08af commit 5b6131e

31 files changed

+391
-401
lines changed

google-maps-in-flutter/codelab_rebuild.yaml

Lines changed: 43 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ steps:
4747
}
4848
]
4949
}
50-
- name: Patch android/app/build.gradle
51-
path: google_maps_in_flutter/android/app/build.gradle
50+
- name: Patch android/app/build.gradle.kts
51+
path: google_maps_in_flutter/android/app/build.gradle.kts
5252
patch-u: |
5353
--- b/google-maps-in-flutter/step_3/android/app/build.gradle
5454
+++ a/google-maps-in-flutter/step_3/android/app/build.gradle
@@ -268,21 +268,12 @@ steps:
268268
@override
269269
Widget build(BuildContext context) {
270270
return MaterialApp(
271-
theme: ThemeData(
272-
useMaterial3: true,
273-
colorSchemeSeed: Colors.green[700],
274-
),
271+
theme: ThemeData(useMaterial3: true, colorSchemeSeed: Colors.green[700]),
275272
home: Scaffold(
276-
appBar: AppBar(
277-
title: const Text('Maps Sample App'),
278-
elevation: 2,
279-
),
273+
appBar: AppBar(title: const Text('Maps Sample App'), elevation: 2),
280274
body: GoogleMap(
281275
onMapCreated: _onMapCreated,
282-
initialCameraPosition: CameraPosition(
283-
target: _center,
284-
zoom: 11.0,
285-
),
276+
initialCameraPosition: CameraPosition(target: _center, zoom: 11.0),
286277
),
287278
),
288279
);
@@ -1256,30 +1247,27 @@ steps:
12561247
* See the License for the specific language governing permissions and
12571248
* limitations under the License.
12581249
*/
1259-
1250+
12601251
import 'dart:convert';
1261-
1252+
12621253
import 'package:flutter/foundation.dart';
12631254
import 'package:flutter/services.dart' show rootBundle;
12641255
import 'package:http/http.dart' as http;
12651256
import 'package:json_annotation/json_annotation.dart';
1266-
1257+
12671258
part 'locations.g.dart';
1268-
1259+
12691260
@JsonSerializable()
12701261
class LatLng {
1271-
LatLng({
1272-
required this.lat,
1273-
required this.lng,
1274-
});
1275-
1262+
LatLng({required this.lat, required this.lng});
1263+
12761264
factory LatLng.fromJson(Map<String, dynamic> json) => _$LatLngFromJson(json);
12771265
Map<String, dynamic> toJson() => _$LatLngToJson(this);
1278-
1266+
12791267
final double lat;
12801268
final double lng;
12811269
}
1282-
1270+
12831271
@JsonSerializable()
12841272
class Region {
12851273
Region({
@@ -1288,16 +1276,16 @@ steps:
12881276
required this.name,
12891277
required this.zoom,
12901278
});
1291-
1279+
12921280
factory Region.fromJson(Map<String, dynamic> json) => _$RegionFromJson(json);
12931281
Map<String, dynamic> toJson() => _$RegionToJson(this);
1294-
1282+
12951283
final LatLng coords;
12961284
final String id;
12971285
final String name;
12981286
final double zoom;
12991287
}
1300-
1288+
13011289
@JsonSerializable()
13021290
class Office {
13031291
Office({
@@ -1310,10 +1298,10 @@ steps:
13101298
required this.phone,
13111299
required this.region,
13121300
});
1313-
1301+
13141302
factory Office.fromJson(Map<String, dynamic> json) => _$OfficeFromJson(json);
13151303
Map<String, dynamic> toJson() => _$OfficeToJson(this);
1316-
1304+
13171305
final String address;
13181306
final String id;
13191307
final String image;
@@ -1323,43 +1311,40 @@ steps:
13231311
final String phone;
13241312
final String region;
13251313
}
1326-
1314+
13271315
@JsonSerializable()
13281316
class Locations {
1329-
Locations({
1330-
required this.offices,
1331-
required this.regions,
1332-
});
1333-
1317+
Locations({required this.offices, required this.regions});
1318+
13341319
factory Locations.fromJson(Map<String, dynamic> json) =>
13351320
_$LocationsFromJson(json);
13361321
Map<String, dynamic> toJson() => _$LocationsToJson(this);
1337-
1322+
13381323
final List<Office> offices;
13391324
final List<Region> regions;
13401325
}
1341-
1326+
13421327
Future<Locations> getGoogleOffices() async {
13431328
const googleLocationsURL = 'https://about.google/static/data/locations.json';
1344-
1329+
13451330
// Retrieve the locations of Google offices
13461331
try {
13471332
final response = await http.get(Uri.parse(googleLocationsURL));
13481333
if (response.statusCode == 200) {
13491334
return Locations.fromJson(
1350-
json.decode(response.body) as Map<String, dynamic>);
1335+
json.decode(response.body) as Map<String, dynamic>,
1336+
);
13511337
}
13521338
} catch (e) {
13531339
if (kDebugMode) {
13541340
print(e);
13551341
}
13561342
}
1357-
1343+
13581344
// Fallback for when the above HTTP request fails.
13591345
return Locations.fromJson(
1360-
json.decode(
1361-
await rootBundle.loadString('assets/locations.json'),
1362-
) as Map<String, dynamic>,
1346+
json.decode(await rootBundle.loadString('assets/locations.json'))
1347+
as Map<String, dynamic>,
13631348
);
13641349
}
13651350
- name: Patch lib/main.dart
@@ -1375,7 +1360,7 @@ steps:
13751360
13761361
void main() {
13771362
runApp(const MyApp());
1378-
@@ -29,12 +30,23 @@ class MyApp extends StatefulWidget {
1363+
@@ -29,12 +30,20 @@ class MyApp extends StatefulWidget {
13791364
}
13801365
13811366
class _MyAppState extends State<MyApp> {
@@ -1394,34 +1379,30 @@ steps:
13941379
+ final marker = Marker(
13951380
+ markerId: MarkerId(office.name),
13961381
+ position: LatLng(office.lat, office.lng),
1397-
+ infoWindow: InfoWindow(
1398-
+ title: office.name,
1399-
+ snippet: office.address,
1400-
+ ),
1382+
+ infoWindow: InfoWindow(title: office.name, snippet: office.address),
14011383
+ );
14021384
+ _markers[office.name] = marker;
14031385
+ }
14041386
+ });
14051387
}
14061388
14071389
@override
1408-
@@ -46,15 +58,16 @@ class _MyAppState extends State<MyApp> {
1409-
),
1390+
@@ -42,10 +51,17 @@ class _MyAppState extends State<MyApp> {
1391+
return MaterialApp(
1392+
theme: ThemeData(useMaterial3: true, colorSchemeSeed: Colors.green[700]),
14101393
home: Scaffold(
1411-
appBar: AppBar(
1412-
- title: const Text('Maps Sample App'),
1394+
- appBar: AppBar(title: const Text('Maps Sample App'), elevation: 2),
1395+
+ appBar: AppBar(
14131396
+ title: const Text('Google Office Locations'),
1414-
elevation: 2,
1415-
),
1397+
+ elevation: 2,
1398+
+ ),
14161399
body: GoogleMap(
14171400
onMapCreated: _onMapCreated,
1418-
- initialCameraPosition: CameraPosition(
1419-
- target: _center,
1420-
- zoom: 11.0,
1401+
- initialCameraPosition: CameraPosition(target: _center, zoom: 11.0),
14211402
+ initialCameraPosition: const CameraPosition(
14221403
+ target: LatLng(0, 0),
14231404
+ zoom: 2,
1424-
),
1405+
+ ),
14251406
+ markers: _markers.values.toSet(),
14261407
),
14271408
),
@@ -1443,6 +1424,9 @@ steps:
14431424
- name: Run build_runner
14441425
path: google_maps_in_flutter
14451426
dart: run build_runner build
1427+
- name: format locations.g.dart
1428+
path: google_maps_in_flutter
1429+
dart: format lib/src/locations.g.dart
14461430
- name: Patch lib/src/locations.g.dart
14471431
path: google_maps_in_flutter/lib/src/locations.g.dart
14481432
patch-u: |

google-maps-in-flutter/step_3/android/app/build.gradle renamed to google-maps-in-flutter/step_3/android/app/build.gradle.kts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
plugins {
2-
id "com.android.application"
3-
id "kotlin-android"
2+
id("com.android.application")
3+
id("kotlin-android")
44
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
5-
id "dev.flutter.flutter-gradle-plugin"
5+
id("dev.flutter.flutter-gradle-plugin")
66
}
77

88
android {
@@ -16,7 +16,7 @@ android {
1616
}
1717

1818
kotlinOptions {
19-
jvmTarget = JavaVersion.VERSION_1_8
19+
jvmTarget = JavaVersion.VERSION_1_8.toString()
2020
}
2121

2222
defaultConfig {
@@ -34,7 +34,7 @@ android {
3434
release {
3535
// TODO: Add your own signing config for the release build.
3636
// Signing with the debug keys for now, so `flutter run --release` works.
37-
signingConfig = signingConfigs.debug
37+
signingConfig = signingConfigs.getByName("debug")
3838
}
3939
}
4040
}

google-maps-in-flutter/step_3/android/build.gradle

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
allprojects {
2+
repositories {
3+
google()
4+
mavenCentral()
5+
}
6+
}
7+
8+
val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get()
9+
rootProject.layout.buildDirectory.value(newBuildDir)
10+
11+
subprojects {
12+
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
13+
project.layout.buildDirectory.value(newSubprojectBuildDir)
14+
}
15+
subprojects {
16+
project.evaluationDependsOn(":app")
17+
}
18+
19+
tasks.register<Delete>("clean") {
20+
delete(rootProject.layout.buildDirectory)
21+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
1+
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
22
android.useAndroidX=true
33
android.enableJetifier=true

google-maps-in-flutter/step_3/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip

google-maps-in-flutter/step_3/android/settings.gradle

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
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+
}
9+
10+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
11+
12+
repositories {
13+
google()
14+
mavenCentral()
15+
gradlePluginPortal()
16+
}
17+
}
18+
19+
plugins {
20+
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
21+
id("com.android.application") version "8.7.0" apply false
22+
id("org.jetbrains.kotlin.android") version "1.8.22" apply false
23+
}
24+
25+
include(":app")

google-maps-in-flutter/step_3/ios/Podfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ flutter_ios_podfile_setup
3030

3131
target 'Runner' do
3232
use_frameworks!
33-
use_modular_headers!
3433

3534
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
3635
target 'RunnerTests' do

0 commit comments

Comments
 (0)