mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 22:09:06 +00:00
Adding flutter_lints (#811)
This commit is contained in:
@@ -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
|
||||
@@ -5,33 +5,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
void main() => runApp(MyApp(Colors.blue));
|
||||
void main() => runApp(const MyApp(color: Colors.blue));
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
void topMain() => runApp(MyApp(Colors.green));
|
||||
void topMain() => runApp(const MyApp(color: Colors.green));
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
void bottomMain() => runApp(MyApp(Colors.purple));
|
||||
void bottomMain() => runApp(const MyApp(color: Colors.purple));
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
MyApp(this.color);
|
||||
const MyApp({Key key, @required this.color}) : super(key: key);
|
||||
|
||||
final Color color;
|
||||
final MaterialColor color;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
theme: ThemeData(
|
||||
primarySwatch: this.color,
|
||||
primarySwatch: color,
|
||||
),
|
||||
home: MyHomePage(title: 'Flutter Demo Home Page'),
|
||||
home: const MyHomePage(title: 'Flutter Demo Home Page'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyHomePage extends StatefulWidget {
|
||||
MyHomePage({Key key, this.title}) : super(key: key);
|
||||
const MyHomePage({Key key, this.title}) : super(key: key);
|
||||
final String title;
|
||||
|
||||
@override
|
||||
@@ -45,8 +45,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_channel = MethodChannel('multiple-flutters');
|
||||
_channel.setMethodCallHandler((MethodCall call) async {
|
||||
_channel = const MethodChannel('multiple-flutters');
|
||||
_channel.setMethodCallHandler((call) async {
|
||||
if (call.method == "setCount") {
|
||||
// A notification that the host platform's data model has been updated.
|
||||
setState(() {
|
||||
@@ -60,7 +60,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
|
||||
void _incrementCounter() {
|
||||
// Mutations to the data model are forwarded to the host platform.
|
||||
_channel.invokeMethod("incrementCount", _counter);
|
||||
_channel.invokeMethod<void>("incrementCount", _counter);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -73,7 +73,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
const Text(
|
||||
'You have pushed the button this many times:',
|
||||
),
|
||||
Text(
|
||||
@@ -82,13 +82,13 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
),
|
||||
TextButton(
|
||||
onPressed: _incrementCounter,
|
||||
child: Text('Add'),
|
||||
child: const Text('Add'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
_channel.invokeMethod("next", _counter);
|
||||
_channel.invokeMethod<void>("next", _counter);
|
||||
},
|
||||
child: Text('Next'),
|
||||
child: const Text('Next'),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -15,6 +15,7 @@ dependencies:
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_lints: ^1.0.0
|
||||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
|
||||
Reference in New Issue
Block a user