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/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
void main() => runApp(MyApp(Colors.blue));
|
void main() => runApp(const MyApp(color: Colors.blue));
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
void topMain() => runApp(MyApp(Colors.green));
|
void topMain() => runApp(const MyApp(color: Colors.green));
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
void bottomMain() => runApp(MyApp(Colors.purple));
|
void bottomMain() => runApp(const MyApp(color: Colors.purple));
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
MyApp(this.color);
|
const MyApp({Key key, @required this.color}) : super(key: key);
|
||||||
|
|
||||||
final Color color;
|
final MaterialColor color;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Flutter Demo',
|
title: 'Flutter Demo',
|
||||||
theme: ThemeData(
|
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 {
|
class MyHomePage extends StatefulWidget {
|
||||||
MyHomePage({Key key, this.title}) : super(key: key);
|
const MyHomePage({Key key, this.title}) : super(key: key);
|
||||||
final String title;
|
final String title;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -45,8 +45,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_channel = MethodChannel('multiple-flutters');
|
_channel = const MethodChannel('multiple-flutters');
|
||||||
_channel.setMethodCallHandler((MethodCall call) async {
|
_channel.setMethodCallHandler((call) async {
|
||||||
if (call.method == "setCount") {
|
if (call.method == "setCount") {
|
||||||
// A notification that the host platform's data model has been updated.
|
// A notification that the host platform's data model has been updated.
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -60,7 +60,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
|
|
||||||
void _incrementCounter() {
|
void _incrementCounter() {
|
||||||
// Mutations to the data model are forwarded to the host platform.
|
// Mutations to the data model are forwarded to the host platform.
|
||||||
_channel.invokeMethod("incrementCount", _counter);
|
_channel.invokeMethod<void>("incrementCount", _counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -73,7 +73,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(
|
const Text(
|
||||||
'You have pushed the button this many times:',
|
'You have pushed the button this many times:',
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
@@ -82,13 +82,13 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: _incrementCounter,
|
onPressed: _incrementCounter,
|
||||||
child: Text('Add'),
|
child: const Text('Add'),
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_channel.invokeMethod("next", _counter);
|
_channel.invokeMethod<void>("next", _counter);
|
||||||
},
|
},
|
||||||
child: Text('Next'),
|
child: const Text('Next'),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -62,11 +62,25 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
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:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
lints:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: lints
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.1"
|
||||||
matcher:
|
matcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ dependencies:
|
|||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
flutter_lints: ^1.0.0
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|||||||
Reference in New Issue
Block a user