mirror of https://github.com/flutter/samples.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.2 KiB
53 lines
1.2 KiB
import 'package:flutter/material.dart';
|
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
|
|
|
class Place {
|
|
final String id;
|
|
final LatLng latLng;
|
|
final String name;
|
|
final PlaceCategory category;
|
|
final String description;
|
|
final int starRating;
|
|
|
|
const Place({
|
|
@required this.id,
|
|
@required this.latLng,
|
|
@required this.name,
|
|
@required this.category,
|
|
this.description,
|
|
this.starRating = 0,
|
|
}) : assert(id != null),
|
|
assert(latLng != null),
|
|
assert(name != null),
|
|
assert(category != null),
|
|
assert(starRating != null && starRating >= 0 && starRating <= 5);
|
|
|
|
double get latitude => latLng.latitude;
|
|
|
|
double get longitude => latLng.longitude;
|
|
|
|
Place copyWith({
|
|
String id,
|
|
LatLng latLng,
|
|
String name,
|
|
PlaceCategory category,
|
|
String description,
|
|
int starRating,
|
|
}) {
|
|
return Place(
|
|
id: id ?? this.id,
|
|
latLng: latLng ?? this.latLng,
|
|
name: name ?? this.name,
|
|
category: category ?? this.category,
|
|
description: description ?? this.description,
|
|
starRating: starRating ?? this.starRating,
|
|
);
|
|
}
|
|
}
|
|
|
|
enum PlaceCategory {
|
|
favorite,
|
|
visited,
|
|
wantToGo,
|
|
}
|