Analysis options, fixes and format (#106)

pull/112/head
Brett Morgan 6 years ago committed by GitHub
parent 90ecd8df25
commit 01478f5e88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,10 +1,30 @@
include: package:pedantic/analysis_options.yaml
analyzer:
errors:
# treat missing required parameters as a warning (not a hint)
missing_required_param: warning
# treat missing returns as a warning (not a hint)
missing_return: warning
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
- unawaited_futures
- avoid_types_on_closure_parameters
- avoid_void_async
- await_only_futures
- camel_case_types
- cancel_subscriptions
- close_sinks
- constant_identifier_names
- control_flow_in_finally
- empty_statements
- hash_and_equals
- implementation_imports
- non_constant_identifier_names
- package_api_docs
- package_names
- package_prefixed_library_names
- test_types_in_equals
- throw_in_finally
- unnecessary_brace_in_string_interps
- unnecessary_getters_setters
- unnecessary_new
- unnecessary_statements

@ -26,19 +26,19 @@ class AppModel<T> extends StatefulWidget {
_AppModelState<T> createState() => _AppModelState<T>();
static _typeOf<T>() => T;
static Type _typeOf<T>() => T;
static T of<T>(BuildContext context) {
final Type appModelScopeType = _typeOf<_AppModelScope<T>>();
final _AppModelScope<T> scope =
context.inheritFromWidgetOfExactType(appModelScopeType);
final _AppModelScope<T> scope = context
.inheritFromWidgetOfExactType(appModelScopeType) as _AppModelScope<T>;
return scope.appModelState.currentState;
}
static void update<T>(BuildContext context, T newState) {
final Type appModelScopeType = _typeOf<_AppModelScope<T>>();
final _AppModelScope<T> scope =
context.inheritFromWidgetOfExactType(appModelScopeType);
final _AppModelScope<T> scope = context
.inheritFromWidgetOfExactType(appModelScopeType) as _AppModelScope<T>;
scope.appModelState.updateState(newState);
}
}

@ -54,7 +54,7 @@ class PlaceDetailsState extends State<PlaceDetails> {
children: <Widget>[
_NameTextField(
controller: _nameController,
onChanged: (String value) {
onChanged: (value) {
setState(() {
_place = _place.copyWith(name: value);
});
@ -62,7 +62,7 @@ class PlaceDetailsState extends State<PlaceDetails> {
),
_DescriptionTextField(
controller: _descriptionController,
onChanged: (String value) {
onChanged: (value) {
setState(() {
_place = _place.copyWith(description: value);
});
@ -70,7 +70,7 @@ class PlaceDetailsState extends State<PlaceDetails> {
),
_StarBar(
rating: _place.starRating,
onChanged: (int value) {
onChanged: (value) {
setState(() {
_place = _place.copyWith(starRating: value);
});
@ -140,7 +140,7 @@ class _NameTextField extends StatelessWidget {
style: const TextStyle(fontSize: 20.0, color: Colors.black87),
autocorrect: true,
controller: controller,
onChanged: (String value) {
onChanged: (value) {
onChanged(value);
},
),
@ -173,7 +173,7 @@ class _DescriptionTextField extends StatelessWidget {
maxLines: null,
autocorrect: true,
controller: controller,
onChanged: (String value) {
onChanged: (value) {
onChanged(value);
},
),
@ -198,7 +198,7 @@ class _StarBar extends StatelessWidget {
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: List.generate(maxStars, (int index) {
children: List.generate(maxStars, (index) {
return IconButton(
icon: const Icon(Icons.star),
iconSize: 40.0,

@ -21,9 +21,8 @@ class PlaceListState extends State<PlaceList> {
void _onPlaceChanged(Place value) {
// Replace the place with the modified version.
final List<Place> newPlaces = List.from(AppState.of(context).places);
final int index =
newPlaces.indexWhere((Place place) => place.id == value.id);
final newPlaces = List<Place>.from(AppState.of(context).places);
final index = newPlaces.indexWhere((place) => place.id == value.id);
newPlaces[index] = value;
AppState.updateWith(context, places: newPlaces);
@ -44,11 +43,11 @@ class PlaceListState extends State<PlaceList> {
shrinkWrap: true,
children: AppState.of(context)
.places
.where((Place place) =>
.where((place) =>
place.category == AppState.of(context).selectedCategory)
.map((Place place) => _PlaceListTile(
.map((place) => _PlaceListTile(
place: place,
onPlaceChanged: (Place value) => _onPlaceChanged(value),
onPlaceChanged: (value) => _onPlaceChanged(value),
))
.toList(),
),
@ -73,12 +72,12 @@ class _PlaceListTile extends StatelessWidget {
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () => Navigator.push(
onTap: () => Navigator.push<void>(
context,
MaterialPageRoute(builder: (context) {
return PlaceDetails(
place: place,
onChanged: (Place value) => onPlaceChanged(value),
onChanged: (value) => onPlaceChanged(value),
);
}),
),
@ -97,7 +96,7 @@ class _PlaceListTile extends StatelessWidget {
maxLines: 3,
),
Row(
children: List.generate(5, (int index) {
children: List.generate(5, (index) {
return Icon(
Icons.star,
size: 28.0,

@ -38,7 +38,7 @@ class PlaceMapState extends State<PlaceMap> {
static List<Place> _getPlacesForCategory(
PlaceCategory category, List<Place> places) {
return places.where((Place place) => place.category == category).toList();
return places.where((place) => place.category == category).toList();
}
Completer<GoogleMapController> mapController = Completer();
@ -55,7 +55,7 @@ class PlaceMapState extends State<PlaceMap> {
MapConfiguration _configuration;
void onMapCreated(GoogleMapController controller) async {
Future<void> onMapCreated(GoogleMapController controller) async {
mapController.complete(controller);
_lastMapPosition = widget.center;
@ -95,12 +95,12 @@ class PlaceMapState extends State<PlaceMap> {
void _pushPlaceDetailsScreen(Place place) {
assert(place != null);
Navigator.push(
Navigator.push<void>(
context,
MaterialPageRoute(builder: (context) {
return PlaceDetails(
place: place,
onChanged: (Place value) => _onPlaceChanged(value),
onChanged: (value) => _onPlaceChanged(value),
);
}),
);
@ -108,9 +108,8 @@ class PlaceMapState extends State<PlaceMap> {
void _onPlaceChanged(Place value) {
// Replace the place with the modified version.
final List<Place> newPlaces = List.from(AppState.of(context).places);
final int index =
newPlaces.indexWhere((Place place) => place.id == value.id);
final newPlaces = List<Place>.from(AppState.of(context).places);
final index = newPlaces.indexWhere((place) => place.id == value.id);
newPlaces[index] = value;
_updateExistingPlaceMarker(place: value);
@ -128,7 +127,7 @@ class PlaceMapState extends State<PlaceMap> {
void _updateExistingPlaceMarker({@required Place place}) {
Marker marker = _markedPlaces.keys
.singleWhere((Marker value) => _markedPlaces[value].id == place.id);
.singleWhere((value) => _markedPlaces[value].id == place.id);
setState(() {
final updatedMarker = marker.copyWith(
@ -208,7 +207,7 @@ class PlaceMapState extends State<PlaceMap> {
);
}
void _onAddPlacePressed() async {
Future<void> _onAddPlacePressed() async {
setState(() {
final newMarker = Marker(
markerId: MarkerId(_lastMapPosition.toString()),
@ -222,11 +221,11 @@ class PlaceMapState extends State<PlaceMap> {
});
}
void _confirmAddPlace(BuildContext context) async {
Future<void> _confirmAddPlace(BuildContext context) async {
if (_pendingMarker != null) {
// Create a new Place and map it to the marker we just added.
final Place newPlace = Place(
id: Uuid().v1(),
id: Uuid().v1() as String,
latLng: _pendingMarker.position,
name: _pendingMarker.infoWindow.title,
category: AppState.of(context).selectedCategory,
@ -321,8 +320,8 @@ class PlaceMapState extends State<PlaceMap> {
// At this point, we know the places have been updated from the list
// view. We need to reconfigure the map to respect the updates.
newConfiguration.places
.where((Place p) => !_configuration.places.contains(p))
.map((Place value) => _updateExistingPlaceMarker(place: value));
.where((p) => !_configuration.places.contains(p))
.map((value) => _updateExistingPlaceMarker(place: value));
await _zoomToFitPlaces(
_getPlacesForCategory(
@ -339,7 +338,7 @@ class PlaceMapState extends State<PlaceMap> {
Widget build(BuildContext context) {
_maybeUpdateMapConfiguration();
return Builder(builder: (BuildContext context) {
return Builder(builder: (context) {
// We need this additional builder here so that we can pass its context to
// _AddPlaceButtonBar's onSavePressed callback. This callback shows a
// SnackBar and to do this, we need a build context that has Scaffold as
@ -559,9 +558,9 @@ class MapConfiguration {
return false;
}
final MapConfiguration otherConfiguration = other;
return otherConfiguration.places == places &&
otherConfiguration.selectedCategory == selectedCategory;
return other is MapConfiguration &&
other.places == places &&
other.selectedCategory == selectedCategory;
}
static MapConfiguration of(AppState appState) {

@ -23,7 +23,7 @@ class _PlaceTrackerAppState extends State<PlaceTrackerApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
builder: (BuildContext context, Widget child) {
builder: (context, child) {
return AppModel<AppState>(
initialState: AppState(),
child: child,
@ -137,10 +137,10 @@ class AppState {
bool operator ==(Object other) {
if (identical(this, other)) return true;
if (other.runtimeType != runtimeType) return false;
final AppState otherAppState = other;
return otherAppState.places == places &&
otherAppState.selectedCategory == selectedCategory &&
otherAppState.viewType == viewType;
return other is AppState &&
other.places == places &&
other.selectedCategory == selectedCategory &&
other.viewType == viewType;
}
@override

@ -89,7 +89,7 @@ packages:
source: hosted
version: "1.6.2"
pedantic:
dependency: transitive
dependency: "direct dev"
description:
name: pedantic
url: "https://pub.dartlang.org"
@ -171,5 +171,5 @@ packages:
source: hosted
version: "2.0.8"
sdks:
dart: ">=2.2.0 <3.0.0"
dart: ">=2.3.0-dev <3.0.0"
flutter: ">=0.11.9 <2.0.0"

@ -4,21 +4,20 @@ description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.2.0 <3.0.0"
sdk: ">=2.3.0-dev <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
google_maps_flutter: ^0.4.0
uuid: 1.0.3
uuid: ^1.0.3
dev_dependencies:
flutter_test:
sdk: flutter
pedantic: ^1.5.0
flutter:
assets:

@ -7,5 +7,5 @@
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('This test always passes', (WidgetTester tester) async {});
testWidgets('This test always passes', (tester) async {});
}

Loading…
Cancel
Save