1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 22:09:06 +00:00

Flutter 3.29 beta (#2571)

This commit is contained in:
Eric Windmill
2025-02-12 18:08:01 -05:00
committed by GitHub
parent d62c784789
commit 719fd72c38
685 changed files with 76244 additions and 53721 deletions

View File

@@ -25,10 +25,7 @@ part 'locations.g.dart';
@JsonSerializable()
class LatLng {
LatLng({
required this.lat,
required this.lng,
});
LatLng({required this.lat, required this.lng});
factory LatLng.fromJson(Map<String, dynamic> json) => _$LatLngFromJson(json);
Map<String, dynamic> toJson() => _$LatLngToJson(this);
@@ -83,10 +80,7 @@ class Office {
@JsonSerializable()
class Locations {
Locations({
required this.offices,
required this.regions,
});
Locations({required this.offices, required this.regions});
factory Locations.fromJson(Map<String, dynamic> json) =>
_$LocationsFromJson(json);
@@ -104,7 +98,8 @@ Future<Locations> getGoogleOffices() async {
final response = await http.get(Uri.parse(googleLocationsURL));
if (response.statusCode == 200) {
return Locations.fromJson(
json.decode(response.body) as Map<String, dynamic>);
json.decode(response.body) as Map<String, dynamic>,
);
}
} catch (e) {
if (kDebugMode) {
@@ -114,8 +109,7 @@ Future<Locations> getGoogleOffices() async {
// Fallback for when the above HTTP request fails.
return Locations.fromJson(
json.decode(
await rootBundle.loadString('assets/locations.json'),
) as Map<String, dynamic>,
json.decode(await rootBundle.loadString('assets/locations.json'))
as Map<String, dynamic>,
);
}