Skip to content

Commit

Permalink
chore: rename lat / lng to latitude / longitude
Browse files Browse the repository at this point in the history
  • Loading branch information
techouse committed Jun 9, 2024
1 parent 554b341 commit e50ceea
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
20 changes: 10 additions & 10 deletions examples/alice_chopper/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ class _MyAppState extends State<MyApp> {
city: 'Springfield',
zipCode: '12345-6789',
geoLocation: GeoLocation(
lat: 37.1234,
lng: -122.1234,
latitude: 37.1234,
longitude: -122.1234,
),
),
company: Company(
Expand Down Expand Up @@ -337,8 +337,8 @@ class _MyAppState extends State<MyApp> {
city: 'New York',
street: '1234 Main St',
geoLocation: johnDoe.address.geoLocation.copyWith(
lat: 40.7128,
lng: -74.0060,
latitude: 40.7128,
longitude: -74.0060,
),
),
),
Expand All @@ -350,8 +350,8 @@ class _MyAppState extends State<MyApp> {
city: 'Los Angeles',
street: '1234 Maple St',
geoLocation: johnDoe.address.geoLocation.copyWith(
lat: 34.0522,
lng: -118.2437,
latitude: 34.0522,
longitude: -118.2437,
),
),
),
Expand All @@ -372,8 +372,8 @@ class _MyAppState extends State<MyApp> {
city: 'Springfield',
zipCode: '12345-6789',
geoLocation: johnDoe.address.geoLocation.copyWith(
lat: 37.1234,
lng: -122.1234,
latitude: 37.1234,
longitude: -122.1234,
),
),
company: johnDoe.company.copyWith(
Expand All @@ -398,8 +398,8 @@ class _MyAppState extends State<MyApp> {
city: 'Springfield',
zipCode: '12345-6789',
geoLocation: johnDoe.address.geoLocation.copyWith(
lat: 37.1234,
lng: -122.1234,
latitude: 37.1234,
longitude: -122.1234,
),
),
company: johnDoe.company.copyWith(
Expand Down
20 changes: 11 additions & 9 deletions examples/alice_chopper/lib/models/geo_location.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,30 @@ part 'geo_location.g.dart';
@JsonSerializable()
class GeoLocation with EquatableMixin {
const GeoLocation({
required this.lat,
required this.lng,
required this.latitude,
required this.longitude,
});

@JsonKey(
name: 'lat',
fromJson: GeoLocation._stringToDouble,
toJson: GeoLocation._doubleToString,
)
final double lat;
final double latitude;
@JsonKey(
name: 'lng',
fromJson: GeoLocation._stringToDouble,
toJson: GeoLocation._doubleToString,
)
final double lng;
final double longitude;

GeoLocation copyWith({
double? lat,
double? lng,
double? latitude,
double? longitude,
}) =>
GeoLocation(
lat: lat ?? this.lat,
lng: lng ?? this.lng,
latitude: latitude ?? this.latitude,
longitude: longitude ?? this.longitude,
);

static String _doubleToString(double value) => value.toString();
Expand All @@ -40,5 +42,5 @@ class GeoLocation with EquatableMixin {
Map<String, dynamic> toJson() => _$GeoLocationToJson(this);

@override
List<Object?> get props => [lat, lng];
List<Object?> get props => [latitude, longitude];
}
8 changes: 4 additions & 4 deletions examples/alice_chopper/lib/models/geo_location.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e50ceea

Please sign in to comment.