mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Flutter 3.29 beta (#2571)
This commit is contained in:
@@ -39,18 +39,15 @@ class _MyAppState extends State<MyApp> {
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.green,
|
||||
),
|
||||
theme: ThemeData(primarySwatch: Colors.green),
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Sydney'), backgroundColor: Colors.green[700]),
|
||||
title: const Text('Sydney'),
|
||||
backgroundColor: Colors.green[700],
|
||||
),
|
||||
body: GoogleMap(
|
||||
onMapCreated: _onMapCreated,
|
||||
initialCameraPosition: CameraPosition(
|
||||
target: _center,
|
||||
zoom: 11.0,
|
||||
),
|
||||
initialCameraPosition: CameraPosition(target: _center, zoom: 11.0),
|
||||
markers: {
|
||||
const Marker(
|
||||
markerId: MarkerId('Sydney'),
|
||||
@@ -59,7 +56,7 @@ class _MyAppState extends State<MyApp> {
|
||||
title: "Sydney",
|
||||
snippet: "Capital of New South Wales",
|
||||
),
|
||||
)
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
@@ -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>,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -23,61 +23,63 @@ part of 'locations.dart';
|
||||
// **************************************************************************
|
||||
|
||||
LatLng _$LatLngFromJson(Map<String, dynamic> json) => LatLng(
|
||||
lat: (json['lat'] as num).toDouble(),
|
||||
lng: (json['lng'] as num).toDouble(),
|
||||
);
|
||||
lat: (json['lat'] as num).toDouble(),
|
||||
lng: (json['lng'] as num).toDouble(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LatLngToJson(LatLng instance) => <String, dynamic>{
|
||||
'lat': instance.lat,
|
||||
'lng': instance.lng,
|
||||
};
|
||||
'lat': instance.lat,
|
||||
'lng': instance.lng,
|
||||
};
|
||||
|
||||
Region _$RegionFromJson(Map<String, dynamic> json) => Region(
|
||||
coords: LatLng.fromJson(json['coords'] as Map<String, dynamic>),
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
zoom: (json['zoom'] as num).toDouble(),
|
||||
);
|
||||
coords: LatLng.fromJson(json['coords'] as Map<String, dynamic>),
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
zoom: (json['zoom'] as num).toDouble(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$RegionToJson(Region instance) => <String, dynamic>{
|
||||
'coords': instance.coords,
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'zoom': instance.zoom,
|
||||
};
|
||||
'coords': instance.coords,
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'zoom': instance.zoom,
|
||||
};
|
||||
|
||||
Office _$OfficeFromJson(Map<String, dynamic> json) => Office(
|
||||
address: json['address'] as String,
|
||||
id: json['id'] as String,
|
||||
image: json['image'] as String,
|
||||
lat: (json['lat'] as num).toDouble(),
|
||||
lng: (json['lng'] as num).toDouble(),
|
||||
name: json['name'] as String,
|
||||
phone: json['phone'] as String,
|
||||
region: json['region'] as String,
|
||||
);
|
||||
address: json['address'] as String,
|
||||
id: json['id'] as String,
|
||||
image: json['image'] as String,
|
||||
lat: (json['lat'] as num).toDouble(),
|
||||
lng: (json['lng'] as num).toDouble(),
|
||||
name: json['name'] as String,
|
||||
phone: json['phone'] as String,
|
||||
region: json['region'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$OfficeToJson(Office instance) => <String, dynamic>{
|
||||
'address': instance.address,
|
||||
'id': instance.id,
|
||||
'image': instance.image,
|
||||
'lat': instance.lat,
|
||||
'lng': instance.lng,
|
||||
'name': instance.name,
|
||||
'phone': instance.phone,
|
||||
'region': instance.region,
|
||||
};
|
||||
'address': instance.address,
|
||||
'id': instance.id,
|
||||
'image': instance.image,
|
||||
'lat': instance.lat,
|
||||
'lng': instance.lng,
|
||||
'name': instance.name,
|
||||
'phone': instance.phone,
|
||||
'region': instance.region,
|
||||
};
|
||||
|
||||
Locations _$LocationsFromJson(Map<String, dynamic> json) => Locations(
|
||||
offices: (json['offices'] as List<dynamic>)
|
||||
offices:
|
||||
(json['offices'] as List<dynamic>)
|
||||
.map((e) => Office.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
regions: (json['regions'] as List<dynamic>)
|
||||
regions:
|
||||
(json['regions'] as List<dynamic>)
|
||||
.map((e) => Region.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LocationsToJson(Locations instance) => <String, dynamic>{
|
||||
'offices': instance.offices,
|
||||
'regions': instance.regions,
|
||||
};
|
||||
'offices': instance.offices,
|
||||
'regions': instance.regions,
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@ publish_to: 'none'
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: ^3.5.0
|
||||
sdk: ^3.7.0-0
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
|
||||
Reference in New Issue
Block a user