1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-10 14:58:34 +00:00

Add flutter_lints to null_safety (#828)

This commit is contained in:
Brett Morgan
2021-06-07 20:53:25 +10:00
committed by GitHub
parent 4069bfbe9e
commit 39b0049345
12 changed files with 86 additions and 12 deletions

View File

@@ -0,0 +1,19 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
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

View File

@@ -5,13 +5,15 @@
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
runApp(const MyApp());
}
// This app simulates possible null errors. Try running it and see if it fails.
// You can then try to hot reload a few times; you should see it occasionally
// failing and occasionally succeeding.
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
// Get data from services. Note: in a real application,
@@ -28,7 +30,7 @@ class MyApp extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Temperature next 3 days:'),
const Text('Temperature next 3 days:'),
for (final t in temperatures) Text(t.round().toString()),
],
),

View File

@@ -62,11 +62,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:

View File

@@ -1,6 +1,6 @@
name: null_unsafe_app
description: A new Flutter project.
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
version: 1.0.0+1
environment:
@@ -14,5 +14,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.0
flutter:
uses-material-design: true

View File

@@ -8,8 +8,7 @@
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Rendering the page throws an exception',
(WidgetTester tester) async {
testWidgets('Rendering the page throws an exception', (tester) async {
// Do nothing, running the app throws an exception on widget render.
});
}