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 : |
0 commit comments