diff --git a/add_to_app/multiple_flutters/multiple_flutters_module/analysis_options.yaml b/add_to_app/multiple_flutters/multiple_flutters_module/analysis_options.yaml new file mode 100644 index 000000000..85f6fbe91 --- /dev/null +++ b/add_to_app/multiple_flutters/multiple_flutters_module/analysis_options.yaml @@ -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 diff --git a/add_to_app/multiple_flutters/multiple_flutters_module/lib/main.dart b/add_to_app/multiple_flutters/multiple_flutters_module/lib/main.dart index 46fa37b36..54895700a 100644 --- a/add_to_app/multiple_flutters/multiple_flutters_module/lib/main.dart +++ b/add_to_app/multiple_flutters/multiple_flutters_module/lib/main.dart @@ -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 { @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 { void _incrementCounter() { // Mutations to the data model are forwarded to the host platform. - _channel.invokeMethod("incrementCount", _counter); + _channel.invokeMethod("incrementCount", _counter); } @override @@ -73,7 +73,7 @@ class _MyHomePageState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text( + const Text( 'You have pushed the button this many times:', ), Text( @@ -82,13 +82,13 @@ class _MyHomePageState extends State { ), TextButton( onPressed: _incrementCounter, - child: Text('Add'), + child: const Text('Add'), ), TextButton( onPressed: () { - _channel.invokeMethod("next", _counter); + _channel.invokeMethod("next", _counter); }, - child: Text('Next'), + child: const Text('Next'), ), ], ), diff --git a/add_to_app/multiple_flutters/multiple_flutters_module/pubspec.lock b/add_to_app/multiple_flutters/multiple_flutters_module/pubspec.lock index 628ebe4e0..2c85bc0f8 100644 --- a/add_to_app/multiple_flutters/multiple_flutters_module/pubspec.lock +++ b/add_to_app/multiple_flutters/multiple_flutters_module/pubspec.lock @@ -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: diff --git a/add_to_app/multiple_flutters/multiple_flutters_module/pubspec.yaml b/add_to_app/multiple_flutters/multiple_flutters_module/pubspec.yaml index 836ca66b6..de990aebf 100644 --- a/add_to_app/multiple_flutters/multiple_flutters_module/pubspec.yaml +++ b/add_to_app/multiple_flutters/multiple_flutters_module/pubspec.yaml @@ -15,6 +15,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + flutter_lints: ^1.0.0 flutter: uses-material-design: true