From dec10b2a8315e2b26e89dba54c0bd05d6378cd01 Mon Sep 17 00:00:00 2001 From: Harsh Bhikadia Date: Wed, 20 Jul 2022 11:35:17 +0530 Subject: [PATCH] chore: added proper lints and fixed some warnings - reapplied plugin template --- .metadata | 24 ++++++++++++++++++++++-- analysis_options.yaml | 15 +++++++++++++++ example/lib/main.dart | 6 ++++-- example/pubspec.yaml | 1 + example/test/widget_test.dart | 7 +++---- lib/receive_intent.dart | 7 +++---- pubspec.yaml | 1 + 7 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 analysis_options.yaml diff --git a/.metadata b/.metadata index 83d6e04..608647a 100644 --- a/.metadata +++ b/.metadata @@ -1,10 +1,30 @@ # This file tracks properties of this Flutter project. # Used by Flutter tool to assess capabilities and perform upgrades etc. # -# This file should be version controlled and should not be manually edited. +# This file should be version controlled. version: - revision: adc687823a831bbebe28bdccfac1a628ca621513 + revision: f1875d570e39de09040c8f79aa13cc56baab8db1 channel: stable project_type: plugin + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + - platform: android + create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..a8a099a --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,15 @@ +include: package:flutter_lints/flutter.yaml + +linter: + rules: + # doc-style related: https://dart.dev/guides/language/effective-dart/documentation + - package_api_docs + - public_member_api_docs + - comment_references + - slash_for_doc_comments + # pub related: https://dart.dev/tools/linter-rules#pub-rules + - depend_on_referenced_packages + - secure_pubspec_urls + # import related + - always_use_package_imports + - implementation_imports diff --git a/example/lib/main.dart b/example/lib/main.dart index 8adfe06..7775d9b 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -4,12 +4,14 @@ import 'package:flutter/material.dart' hide Intent; import 'package:receive_intent/receive_intent.dart'; void main() { - runApp(MyApp()); + runApp(const MyApp()); } class MyApp extends StatefulWidget { + const MyApp({Key key}) : super(key: key); + @override - _MyAppState createState() => _MyAppState(); + State createState() => _MyAppState(); } class _MyAppState extends State { diff --git a/example/pubspec.yaml b/example/pubspec.yaml index affc5c7..8f48649 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -27,6 +27,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + flutter_lints: ^2.0.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index c5fdc04..1bd4ef6 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -7,19 +7,18 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; - import 'package:receive_intent_example/main.dart'; void main() { testWidgets('Verify Platform version', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); + await tester.pumpWidget(const MyApp()); // Verify that platform version is retrieved. expect( find.byWidgetPredicate( - (Widget widget) => widget is Text && - widget.data.startsWith('Running on:'), + (Widget widget) => + widget is Text && widget.data.startsWith('Running on:'), ), findsOneWidget, ); diff --git a/lib/receive_intent.dart b/lib/receive_intent.dart index 72bcc10..5a88e0d 100644 --- a/lib/receive_intent.dart +++ b/lib/receive_intent.dart @@ -64,10 +64,9 @@ class Intent { } class ReceiveIntent { - static const MethodChannel _methodChannel = - const MethodChannel('receive_intent'); + static const MethodChannel _methodChannel = MethodChannel('receive_intent'); static const EventChannel _eventChannel = - const EventChannel("receive_intent/event"); + EventChannel("receive_intent/event"); static Future getInitialIntent() async { final renameMap = await _methodChannel.invokeMapMethod('getInitialIntent'); @@ -80,7 +79,7 @@ class ReceiveIntent { .map((event) => Intent.fromMap(event as Map?)); static Future setResult(int resultCode, - {Map? data, bool shouldFinish: false}) async { + {Map? data, bool shouldFinish = false}) async { await _methodChannel.invokeMethod('setResult', { "resultCode": resultCode, if (data != null) "data": json.encode(data), diff --git a/pubspec.yaml b/pubspec.yaml index 59b47b1..0712bce 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,6 +14,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + flutter_lints: ^2.0.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec