mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Beta (#1234)
This commit is contained in:
@@ -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 = {};
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -82,7 +82,7 @@ packages:
|
||||
name: flutter_lints
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
version: "2.0.1"
|
||||
flutter_plugin_android_lifecycle:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -155,7 +155,7 @@ packages:
|
||||
name: lints
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
version: "2.0.0"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -295,5 +295,5 @@ packages:
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
sdks:
|
||||
dart: ">=2.14.0 <3.0.0"
|
||||
dart: ">=2.17.0-206.0.dev <3.0.0"
|
||||
flutter: ">=2.5.0"
|
||||
|
||||
@@ -4,7 +4,7 @@ description: A new Flutter project.
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
sdk: ">=2.17.0-0 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
@@ -19,7 +19,7 @@ dependencies:
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_lints: ^1.0.0
|
||||
flutter_lints: ^2.0.1
|
||||
|
||||
flutter:
|
||||
assets:
|
||||
|
||||
Reference in New Issue
Block a user