1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-10 23:08:59 +00:00

Upgrading samples to flutter_lints, part 1 of n (#804)

This commit is contained in:
Brett Morgan
2021-06-05 12:24:28 +10:00
committed by GitHub
parent 14921d0c06
commit 936d1fdaae
230 changed files with 2361 additions and 2444 deletions

View File

@@ -1,4 +1,4 @@
include: package:pedantic/analysis_options.1.11.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

View File

@@ -33,19 +33,19 @@ class _HomePageState extends State<HomePage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Federated Plugin Demo'),
title: const Text('Federated Plugin Demo'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
batteryLevel == null
? SizedBox.shrink()
? const SizedBox.shrink()
: Text(
'Battery Level: $batteryLevel',
style: Theme.of(context).textTheme.headline5,
),
SizedBox(height: 16),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () async {
try {
@@ -64,7 +64,7 @@ class _HomePageState extends State<HomePage> {
);
}
},
child: Text('Get Battery Level'),
child: const Text('Get Battery Level'),
),
],
),

View File

@@ -97,6 +97,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_test:
dependency: "direct dev"
description: flutter
@@ -114,6 +121,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
lints:
dependency: transitive
description:
name: lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
matcher:
dependency: transitive
description:
@@ -135,13 +149,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.11.0"
plugin_platform_interface:
dependency: transitive
description:

View File

@@ -1,7 +1,7 @@
name: federated_plugin_example
description: Demonstrates how to use the federated_plugin plugin.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
publish_to: "none" # Remove this line if you wish to publish to pub.dev
environment:
sdk: ">=2.12.0 <3.0.0"
@@ -17,7 +17,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
pedantic: ^1.11.0
flutter_lints: ^1.0.0
flutter:
uses-material-design: true

View File

@@ -9,9 +9,9 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
group('federated plugin demo tests', () {
final batteryLevel = 45;
const batteryLevel = 45;
setUpAll(() {
MethodChannel('battery').setMockMethodCallHandler((call) async {
const MethodChannel('battery').setMockMethodCallHandler((call) async {
if (call.method == 'getBatteryLevel') {
return batteryLevel;
}

View File

@@ -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_test:
dependency: "direct dev"
description: flutter
@@ -100,6 +107,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
lints:
dependency: transitive
description:
name: lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
matcher:
dependency: transitive
description:
@@ -121,13 +135,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.11.0"
plugin_platform_interface:
dependency: transitive
description:

View File

@@ -1,9 +1,8 @@
name: federated_plugin
description: A new flutter plugin project to demonstrate how to implement federated plugin.
version: 0.0.1
homepage:
publish_to: 'none'
publish_to: "none"
environment:
sdk: ">=2.12.0 <3.0.0"
@@ -24,7 +23,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
pedantic: ^1.11.0
flutter_lints: ^1.0.0
flutter:
plugin:

View File

@@ -10,8 +10,8 @@ void main() {
TestWidgetsFlutterBinding.ensureInitialized();
group('Federated Plugin Test', () {
final batteryLevel = 34;
MethodChannel('battery').setMockMethodCallHandler((call) async {
const batteryLevel = 34;
const MethodChannel('battery').setMockMethodCallHandler((call) async {
if (call.method == 'getBatteryLevel') {
return batteryLevel;
}