1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 13:58:47 +00:00
This commit is contained in:
Brett Morgan
2022-05-11 12:48:11 -07:00
committed by GitHub
parent fb00d0a102
commit ccd68f34e2
242 changed files with 1719 additions and 1430 deletions

View File

@@ -19,10 +19,10 @@ class PlaceDetails extends StatefulWidget {
}) : super(key: key);
@override
PlaceDetailsState createState() => PlaceDetailsState();
State<PlaceDetails> createState() => _PlaceDetailsState();
}
class PlaceDetailsState extends State<PlaceDetails> {
class _PlaceDetailsState extends State<PlaceDetails> {
late Place _place;
GoogleMapController? _mapController;
final Set<Marker> _markers = {};

View File

@@ -13,10 +13,10 @@ class PlaceList extends StatefulWidget {
const PlaceList({Key? key}) : super(key: key);
@override
PlaceListState createState() => PlaceListState();
State<PlaceList> createState() => _PlaceListState();
}
class PlaceListState extends State<PlaceList> {
class _PlaceListState extends State<PlaceList> {
final ScrollController _scrollController = ScrollController();
@override
@@ -77,16 +77,16 @@ class _CategoryButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
late String _buttonText;
late String buttonText;
switch (category) {
case PlaceCategory.favorite:
_buttonText = 'Favorites';
buttonText = 'Favorites';
break;
case PlaceCategory.visited:
_buttonText = 'Visited';
buttonText = 'Visited';
break;
case PlaceCategory.wantToGo:
_buttonText = 'Want To Go';
buttonText = 'Want To Go';
}
return Container(
@@ -102,7 +102,7 @@ class _CategoryButton extends StatelessWidget {
height: 50.0,
child: TextButton(
child: Text(
_buttonText,
buttonText,
style: TextStyle(
fontSize: selected ? 20.0 : 18.0,
color: selected ? Colors.blue : Colors.black87,

View File

@@ -59,10 +59,10 @@ class PlaceMap extends StatefulWidget {
}) : super(key: key);
@override
PlaceMapState createState() => PlaceMapState();
State<PlaceMap> createState() => _PlaceMapState();
}
class PlaceMapState extends State<PlaceMap> {
class _PlaceMapState extends State<PlaceMap> {
Completer<GoogleMapController> mapController = Completer();
MapType _currentMapType = MapType.normal;
@@ -170,16 +170,18 @@ class PlaceMapState extends State<PlaceMap> {
Future<void> _confirmAddPlace(BuildContext context) async {
if (_pendingMarker != null) {
// Create a new Place and map it to the marker we just added.
final appState = Provider.of<AppState>(context, listen: false);
final newPlace = Place(
id: const Uuid().v1(),
latLng: _pendingMarker!.position,
name: _pendingMarker!.infoWindow.title!,
category:
Provider.of<AppState>(context, listen: false).selectedCategory,
category: appState.selectedCategory,
);
var placeMarker = await _getPlaceMarkerIcon(context,
Provider.of<AppState>(context, listen: false).selectedCategory);
final scaffoldMessenger = ScaffoldMessenger.of(context);
var placeMarker =
await _getPlaceMarkerIcon(context, appState.selectedCategory);
setState(() {
final updatedMarker = _pendingMarker!.copyWith(
@@ -202,7 +204,7 @@ class PlaceMapState extends State<PlaceMap> {
});
// Show a confirmation snackbar that has an action to edit the new place.
ScaffoldMessenger.of(context).showSnackBar(
scaffoldMessenger.showSnackBar(
SnackBar(
duration: const Duration(seconds: 3),
content:
@@ -217,20 +219,17 @@ class PlaceMapState extends State<PlaceMap> {
);
// Add the new place to the places stored in appState.
final newPlaces =
List<Place>.from(Provider.of<AppState>(context, listen: false).places)
..add(newPlace);
final newPlaces = List<Place>.from(appState.places)..add(newPlace);
// Manually update our map configuration here since our map is already
// updated with the new marker. Otherwise, the map would be reconfigured
// in the main build method due to a modified AppState.
_configuration = MapConfiguration(
places: newPlaces,
selectedCategory:
Provider.of<AppState>(context, listen: false).selectedCategory,
selectedCategory: appState.selectedCategory,
);
Provider.of<AppState>(context, listen: false).setPlaces(newPlaces);
appState.setPlaces(newPlaces);
}
}
@@ -472,19 +471,19 @@ class _AddPlaceButtonBar extends StatelessWidget {
children: [
ElevatedButton(
style: ElevatedButton.styleFrom(primary: Colors.blue),
onPressed: onSavePressed,
child: const Text(
'Save',
style: TextStyle(color: Colors.white, fontSize: 16.0),
),
onPressed: onSavePressed,
),
ElevatedButton(
style: ElevatedButton.styleFrom(primary: Colors.red),
onPressed: onCancelPressed,
child: const Text(
'Cancel',
style: TextStyle(color: Colors.white, fontSize: 16.0),
),
onPressed: onCancelPressed,
),
],
),