mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Add Google Maps Place Tracker sample app to flutter/samples. (#20)
Sample app that displays places on a map. Add/edit places. Interact with map. Iterations to follow.
This commit is contained in:
46
place_tracker/lib/place.dart
Normal file
46
place_tracker/lib/place.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
|
||||
enum PlaceCategory {
|
||||
favorite,
|
||||
visited,
|
||||
wantToGo,
|
||||
}
|
||||
|
||||
class Place {
|
||||
const Place({
|
||||
@required this.latLng,
|
||||
@required this.name,
|
||||
@required this.category,
|
||||
this.description,
|
||||
this.starRating = 0,
|
||||
}) : assert(latLng != null),
|
||||
assert(name != null),
|
||||
assert(category != null),
|
||||
assert(starRating != null && starRating >= 0 && starRating <= 5);
|
||||
|
||||
final LatLng latLng;
|
||||
final String name;
|
||||
final PlaceCategory category;
|
||||
final String description;
|
||||
final int starRating;
|
||||
|
||||
double get latitude => latLng.latitude;
|
||||
double get longitude => latLng.longitude;
|
||||
|
||||
Place copyWith({
|
||||
LatLng latLng,
|
||||
String name,
|
||||
PlaceCategory category,
|
||||
String description,
|
||||
int starRating,
|
||||
}) {
|
||||
return Place(
|
||||
latLng: latLng ?? this.latLng,
|
||||
name: name ?? this.name,
|
||||
category: category ?? this.category,
|
||||
description: description ?? this.description,
|
||||
starRating: starRating ?? this.starRating,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user