mirror of
https://github.com/flutter/samples.git
synced 2026-03-22 04:17:50 +00:00
Upgrading samples to flutter_lints, part 1 of n (#804)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
include: package:pedantic/analysis_options.1.9.0.yaml
|
||||
include: package:flutter_lints/flutter.yaml
|
||||
|
||||
analyzer:
|
||||
strong-mode:
|
||||
@@ -7,25 +7,14 @@ analyzer:
|
||||
|
||||
linter:
|
||||
rules:
|
||||
- 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
|
||||
- directives_ordering
|
||||
- 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
|
||||
avoid_types_on_closure_parameters: true
|
||||
avoid_void_async: true
|
||||
cancel_subscriptions: true
|
||||
close_sinks: true
|
||||
directives_ordering: true
|
||||
package_api_docs: true
|
||||
package_prefixed_library_names: true
|
||||
test_types_in_equals: true
|
||||
throw_in_finally: true
|
||||
unnecessary_statements: true
|
||||
use_key_in_widget_constructors: false
|
||||
|
||||
@@ -37,7 +37,7 @@ class PlaceDetailsState extends State<PlaceDetails> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('${_place.name}'),
|
||||
title: Text(_place.name),
|
||||
backgroundColor: Colors.green[700],
|
||||
actions: [
|
||||
Padding(
|
||||
|
||||
@@ -92,7 +92,7 @@ class _CategoryButton extends StatelessWidget {
|
||||
}
|
||||
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 12.0),
|
||||
margin: const EdgeInsets.symmetric(vertical: 12.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
@@ -179,14 +179,14 @@ class _PlaceListTile extends StatelessWidget {
|
||||
}),
|
||||
),
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(top: 16.0),
|
||||
padding: const EdgeInsets.only(top: 16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
place.name,
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20.0,
|
||||
),
|
||||
@@ -209,7 +209,7 @@ class _PlaceListTile extends StatelessWidget {
|
||||
maxLines: 4,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
const SizedBox(height: 16.0),
|
||||
Divider(
|
||||
height: 2.0,
|
||||
color: Colors.grey[700],
|
||||
|
||||
@@ -206,7 +206,7 @@ class PlaceMapState extends State<PlaceMap> {
|
||||
// Show a confirmation snackbar that has an action to edit the new place.
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
duration: Duration(seconds: 3),
|
||||
duration: const Duration(seconds: 3),
|
||||
content:
|
||||
const Text('New place added.', style: TextStyle(fontSize: 16.0)),
|
||||
action: SnackBarAction(
|
||||
@@ -293,7 +293,7 @@ class PlaceMapState extends State<PlaceMap> {
|
||||
final newMarker = Marker(
|
||||
markerId: MarkerId(_lastMapPosition.toString()),
|
||||
position: _lastMapPosition,
|
||||
infoWindow: InfoWindow(title: 'New Place'),
|
||||
infoWindow: const InfoWindow(title: 'New Place'),
|
||||
draggable: true,
|
||||
icon: BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueGreen),
|
||||
);
|
||||
@@ -433,12 +433,12 @@ class PlaceMapState extends State<PlaceMap> {
|
||||
switch (category) {
|
||||
case PlaceCategory.favorite:
|
||||
return BitmapDescriptor.fromAssetImage(
|
||||
createLocalImageConfiguration(context, size: Size.square(32)),
|
||||
createLocalImageConfiguration(context, size: const Size.square(32)),
|
||||
'assets/heart.png');
|
||||
break;
|
||||
case PlaceCategory.visited:
|
||||
return BitmapDescriptor.fromAssetImage(
|
||||
createLocalImageConfiguration(context, size: Size.square(32)),
|
||||
createLocalImageConfiguration(context, size: const Size.square(32)),
|
||||
'assets/visited.png');
|
||||
break;
|
||||
case PlaceCategory.wantToGo:
|
||||
@@ -598,7 +598,7 @@ class _MapFabs extends StatelessWidget {
|
||||
backgroundColor: Colors.green,
|
||||
child: const Icon(Icons.add_location, size: 36.0),
|
||||
),
|
||||
SizedBox(height: 12.0),
|
||||
const SizedBox(height: 12.0),
|
||||
FloatingActionButton(
|
||||
heroTag: 'toggle_map_type_button',
|
||||
onPressed: onToggleMapTypePressed,
|
||||
|
||||
@@ -19,7 +19,7 @@ enum PlaceTrackerViewType {
|
||||
class PlaceTrackerApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
return const MaterialApp(
|
||||
home: _PlaceTrackerHomePage(),
|
||||
);
|
||||
}
|
||||
@@ -46,7 +46,7 @@ class _PlaceTrackerHomePage extends StatelessWidget {
|
||||
backgroundColor: Colors.green[700],
|
||||
actions: [
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(0.0, 0.0, 16.0, 0.0),
|
||||
padding: const EdgeInsets.fromLTRB(0.0, 0.0, 16.0, 0.0),
|
||||
child: IconButton(
|
||||
icon: Icon(
|
||||
state.viewType == PlaceTrackerViewType.map
|
||||
@@ -67,8 +67,8 @@ class _PlaceTrackerHomePage extends StatelessWidget {
|
||||
),
|
||||
body: IndexedStack(
|
||||
index: state.viewType == PlaceTrackerViewType.map ? 0 : 1,
|
||||
children: [
|
||||
PlaceMap(center: const LatLng(45.521563, -122.677433)),
|
||||
children: const [
|
||||
PlaceMap(center: LatLng(45.521563, -122.677433)),
|
||||
PlaceList()
|
||||
],
|
||||
),
|
||||
|
||||
@@ -83,6 +83,13 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: flutter_lints
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.3"
|
||||
flutter_plugin_android_lifecycle:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -149,6 +156,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.5.0"
|
||||
lints:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: lints
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -177,13 +191,6 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.0"
|
||||
pedantic:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.9.2"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -19,7 +19,7 @@ dependencies:
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
pedantic: ^1.9.0
|
||||
flutter_lints: ^1.0.0
|
||||
|
||||
flutter:
|
||||
assets:
|
||||
|
||||
Reference in New Issue
Block a user