1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-10 14:58:34 +00:00
Files
samples/place_tracker/lib/place.dart
Kenzie Schmoll 79d9d143b4 Add a list view to the place tracker app. (#30)
* Add list view to place tracker. Note: map in listTile is not WAI in this commit.

* Remove map from list tiles. Make list tiles tappable (currently editing a place and saving will do nothing if the details screen is pushed from the list view.

* Fix text alignment in list.

* Initial implementation of using an InheritedWidget to maintain data between list and map. Map does not update correctly at this point.

* Use AppModel.update to set the AppState. Add MapConfiguration class to handle map changes based on AppState.

* Don't cache AppState - lookup directly. Extract AppState code into it's own file and add static methods. Address comments from Hans.

* Extract generic AppModel code.
2018-11-13 10:39:06 -08:00

52 lines
1.2 KiB
Dart

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.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);
final String id;
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({
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,
);
}
}