mirror of
https://github.com/flutter/samples.git
synced 2026-04-14 02:51:15 +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
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:Runner.xcodeproj">
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
final appTheme = ThemeData(
|
||||
primarySwatch: Colors.yellow,
|
||||
textTheme: TextTheme(
|
||||
textTheme: const TextTheme(
|
||||
headline1: TextStyle(
|
||||
fontFamily: 'Corben',
|
||||
fontWeight: FontWeight.w700,
|
||||
|
||||
@@ -24,7 +24,7 @@ class MyCart extends StatelessWidget {
|
||||
child: _CartList(),
|
||||
),
|
||||
),
|
||||
Divider(height: 4, color: Colors.black),
|
||||
const Divider(height: 4, color: Colors.black),
|
||||
_CartTotal()
|
||||
],
|
||||
),
|
||||
@@ -45,9 +45,9 @@ class _CartList extends StatelessWidget {
|
||||
return ListView.builder(
|
||||
itemCount: cart.items.length,
|
||||
itemBuilder: (context, index) => ListTile(
|
||||
leading: Icon(Icons.done),
|
||||
leading: const Icon(Icons.done),
|
||||
trailing: IconButton(
|
||||
icon: Icon(Icons.remove_circle_outline),
|
||||
icon: const Icon(Icons.remove_circle_outline),
|
||||
onPressed: () {
|
||||
cart.remove(cart.items[index]);
|
||||
},
|
||||
@@ -82,14 +82,14 @@ class _CartTotal extends StatelessWidget {
|
||||
Consumer<CartModel>(
|
||||
builder: (context, cart, child) =>
|
||||
Text('\$${cart.totalPrice}', style: hugeStyle)),
|
||||
SizedBox(width: 24),
|
||||
const SizedBox(width: 24),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Buying not supported yet.')));
|
||||
const SnackBar(content: Text('Buying not supported yet.')));
|
||||
},
|
||||
style: TextButton.styleFrom(primary: Colors.white),
|
||||
child: Text('BUY'),
|
||||
child: const Text('BUY'),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -14,7 +14,7 @@ class MyCatalog extends StatelessWidget {
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
_MyAppBar(),
|
||||
SliverToBoxAdapter(child: SizedBox(height: 12)),
|
||||
const SliverToBoxAdapter(child: SizedBox(height: 12)),
|
||||
SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) => _MyListItem(index)),
|
||||
@@ -62,7 +62,9 @@ class _AddButton extends StatelessWidget {
|
||||
return null; // Defer to the widget's default.
|
||||
}),
|
||||
),
|
||||
child: isInCart ? Icon(Icons.check, semanticLabel: 'ADDED') : Text('ADD'),
|
||||
child: isInCart
|
||||
? const Icon(Icons.check, semanticLabel: 'ADDED')
|
||||
: const Text('ADD'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -75,7 +77,7 @@ class _MyAppBar extends StatelessWidget {
|
||||
floating: true,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.shopping_cart),
|
||||
icon: const Icon(Icons.shopping_cart),
|
||||
onPressed: () => Navigator.pushNamed(context, '/cart'),
|
||||
),
|
||||
],
|
||||
@@ -86,7 +88,7 @@ class _MyAppBar extends StatelessWidget {
|
||||
class _MyListItem extends StatelessWidget {
|
||||
final int index;
|
||||
|
||||
_MyListItem(this.index, {Key? key}) : super(key: key);
|
||||
const _MyListItem(this.index, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -109,11 +111,11 @@ class _MyListItem extends StatelessWidget {
|
||||
color: item.color,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 24),
|
||||
const SizedBox(width: 24),
|
||||
Expanded(
|
||||
child: Text(item.name, style: textTheme),
|
||||
),
|
||||
SizedBox(width: 24),
|
||||
const SizedBox(width: 24),
|
||||
_AddButton(item: item),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -10,7 +10,7 @@ class MyLogin extends StatelessWidget {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(80.0),
|
||||
padding: const EdgeInsets.all(80.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
@@ -19,21 +19,21 @@ class MyLogin extends StatelessWidget {
|
||||
style: Theme.of(context).textTheme.headline1,
|
||||
),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Username',
|
||||
),
|
||||
),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Password',
|
||||
),
|
||||
obscureText: true,
|
||||
),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
ElevatedButton(
|
||||
child: Text('ENTER'),
|
||||
child: const Text('ENTER'),
|
||||
onPressed: () {
|
||||
Navigator.pushReplacementNamed(context, '/catalog');
|
||||
},
|
||||
|
||||
@@ -55,11 +55,25 @@ 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_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
lints:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: lints
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -88,20 +102,13 @@ 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.10.0"
|
||||
provider:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: provider
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "5.0.0-nullsafety.5"
|
||||
version: "5.0.0"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
|
||||
@@ -4,19 +4,19 @@ description: A shopping app sample that uses Provider for state management.
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: '>=2.12.0-259.16.beta <3.0.0'
|
||||
sdk: ">=2.12.0 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
# Import the provider package.
|
||||
provider: '>=5.0.0-nullsafety.5 <6.0.0'
|
||||
provider: ^5.0.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
pedantic: ^1.10.0
|
||||
flutter_lints: ^1.0.0
|
||||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
|
||||
Reference in New Issue
Block a user