chore(lint): update lint rules

This commit is contained in:
ricardodalarme 2024-01-09 14:48:01 -03:00
parent 146ec762b2
commit b3ae883683
6 changed files with 39 additions and 29 deletions

View File

@ -1,33 +1,35 @@
include: package:flutter_lints/flutter.yaml
analyzer: analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true
errors: errors:
annotate_overrides: error collection_methods_unrelated_type: warning
avoid_shadowing_type_parameters: warning missing_required_param: error
exhaustive_cases: warning missing_return: error
literal_only_boolean_expressions: warning record_literal_one_positional_no_trailing_comma: error
missing_required_param: warning unrelated_type_equality_checks: warning
missing_return: warning
no_duplicate_case_values: error
only_throw_errors: error
override_on_non_overriding_member: error
unnecessary_overrides: error
linter: linter:
rules: rules:
- always_declare_return_types - always_declare_return_types
- always_put_required_named_parameters_first
- always_use_package_imports
- annotate_overrides - annotate_overrides
- avoid_bool_literals_in_conditional_expressions - avoid_bool_literals_in_conditional_expressions
- avoid_catching_errors - avoid_catching_errors
- avoid_double_and_int_checks
- avoid_dynamic_calls - avoid_dynamic_calls
- avoid_empty_else - avoid_empty_else
- avoid_equals_and_hash_code_on_mutable_classes
- avoid_escaping_inner_quotes - avoid_escaping_inner_quotes
- avoid_field_initializers_in_const_classes - avoid_field_initializers_in_const_classes
- avoid_final_parameters - avoid_final_parameters
- avoid_function_literals_in_foreach_calls - avoid_function_literals_in_foreach_calls
- avoid_implementing_value_types
- avoid_init_to_null - avoid_init_to_null
- avoid_js_rounded_ints - avoid_js_rounded_ints
- avoid_multiple_declarations_per_line
- avoid_null_checks_in_equality_operators - avoid_null_checks_in_equality_operators
- avoid_print - avoid_print
- avoid_private_typedef_functions - avoid_private_typedef_functions
@ -54,15 +56,16 @@ linter:
- cast_nullable_to_non_nullable - cast_nullable_to_non_nullable
- close_sinks - close_sinks
- collection_methods_unrelated_type - collection_methods_unrelated_type
- combinators_ordering
- comment_references - comment_references
- conditional_uri_does_not_exist - conditional_uri_does_not_exist
- constant_identifier_names - constant_identifier_names
- control_flow_in_finally - control_flow_in_finally
- curly_braces_in_flow_control_structures - curly_braces_in_flow_control_structures
- dangling_library_doc_comments
- depend_on_referenced_packages - depend_on_referenced_packages
- deprecated_consistency - deprecated_consistency
- directives_ordering - directives_ordering
- discarded_futures
- empty_catches - empty_catches
- empty_constructor_bodies - empty_constructor_bodies
- empty_statements - empty_statements
@ -71,21 +74,25 @@ linter:
- file_names - file_names
- hash_and_equals - hash_and_equals
- implementation_imports - implementation_imports
- iterable_contains_unrelated_type - implicit_call_tearoffs
- implicit_reopen
- invalid_case_patterns
- join_return_with_assignment - join_return_with_assignment
- leading_newlines_in_multiline_strings - leading_newlines_in_multiline_strings
- library_names - library_names
- library_prefixes - library_prefixes
- library_private_types_in_public_api - library_private_types_in_public_api
- list_remove_unrelated_type
- literal_only_boolean_expressions - literal_only_boolean_expressions
- matching_super_parameters
- missing_whitespace_between_adjacent_strings - missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list - no_adjacent_strings_in_list
- no_duplicate_case_values - no_duplicate_case_values
- no_leading_underscores_for_library_prefixes - no_leading_underscores_for_library_prefixes
- no_leading_underscores_for_local_identifiers - no_leading_underscores_for_local_identifiers
- no_literal_bool_comparisons
- no_logic_in_create_state - no_logic_in_create_state
- no_runtimeType_toString - no_runtimeType_toString
- no_wildcard_variable_uses
- non_constant_identifier_names - non_constant_identifier_names
- noop_primitive_operations - noop_primitive_operations
- null_check_on_nullable_type_parameter - null_check_on_nullable_type_parameter
@ -93,7 +100,6 @@ linter:
- omit_local_variable_types - omit_local_variable_types
- only_throw_errors - only_throw_errors
- overridden_fields - overridden_fields
- package_api_docs
- package_names - package_names
- package_prefixed_library_names - package_prefixed_library_names
- parameter_assignments - parameter_assignments
@ -132,10 +138,12 @@ linter:
- provide_deprecation_message - provide_deprecation_message
- recursive_getters - recursive_getters
- require_trailing_commas - require_trailing_commas
- secure_pubspec_urls
- sized_box_for_whitespace - sized_box_for_whitespace
- sized_box_shrink_expand - sized_box_shrink_expand
- slash_for_doc_comments - slash_for_doc_comments
- sort_child_properties_last - sort_child_properties_last
- sort_pub_dependencies
- sort_unnamed_constructors_first - sort_unnamed_constructors_first
- test_types_in_equals - test_types_in_equals
- throw_in_finally - throw_in_finally
@ -145,6 +153,7 @@ linter:
- unawaited_futures - unawaited_futures
- unnecessary_await_in_return - unnecessary_await_in_return
- unnecessary_brace_in_string_interps - unnecessary_brace_in_string_interps
- unnecessary_breaks
- unnecessary_const - unnecessary_const
- unnecessary_constructor_name - unnecessary_constructor_name
- unnecessary_getters_setters - unnecessary_getters_setters
@ -171,15 +180,17 @@ linter:
- use_enums - use_enums
- use_full_hex_values_for_flutter_colors - use_full_hex_values_for_flutter_colors
- use_function_type_syntax_for_parameters - use_function_type_syntax_for_parameters
- use_if_null_to_convert_nulls_to_bools
- use_is_even_rather_than_modulo - use_is_even_rather_than_modulo
- use_key_in_widget_constructors - use_key_in_widget_constructors
- use_late_for_private_fields_and_variables
- use_named_constants - use_named_constants
- use_raw_strings - use_raw_strings
- use_rethrow_when_possible - use_rethrow_when_possible
- use_setters_to_change_properties - use_setters_to_change_properties
- use_string_buffers - use_string_buffers
- use_string_in_part_of_directives
- use_super_parameters - use_super_parameters
- use_test_throws_matchers
- use_to_and_as_if_applicable - use_to_and_as_if_applicable
- valid_regexps - valid_regexps
- void_checks - void_checks

View File

@ -1,10 +1,10 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
class ExampleCandidateModel { class ExampleCandidateModel {
String name; final String name;
String job; final String job;
String city; final String city;
List<Color> color; final List<Color> color;
ExampleCandidateModel({ ExampleCandidateModel({
required this.name, required this.name,

View File

@ -1,7 +1,6 @@
import 'package:example/example_candidate_model.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'example_candidate_model.dart';
class ExampleCard extends StatelessWidget { class ExampleCard extends StatelessWidget {
final ExampleCandidateModel candidate; final ExampleCandidateModel candidate;
@ -23,7 +22,7 @@ class ExampleCard extends StatelessWidget {
spreadRadius: 3, spreadRadius: 3,
blurRadius: 7, blurRadius: 7,
offset: const Offset(0, 3), offset: const Offset(0, 3),
) ),
], ],
), ),
alignment: Alignment.center, alignment: Alignment.center,
@ -66,7 +65,7 @@ class ExampleCard extends StatelessWidget {
Text( Text(
candidate.city, candidate.city,
style: const TextStyle(color: Colors.grey), style: const TextStyle(color: Colors.grey),
) ),
], ],
), ),
), ),

View File

@ -117,7 +117,8 @@ class CardAnimation {
void updateDifference() { void updateDifference() {
final discrepancy = (total / 10).abs(); final discrepancy = (total / 10).abs();
var diffX = 0.0, diffY = 0.0; var diffX = 0.0;
var diffY = 0.0;
if (initialOffset.dx > 0) { if (initialOffset.dx > 0) {
diffX = discrepancy; diffX = discrepancy;

View File

@ -127,9 +127,9 @@ class CardSwiper extends StatefulWidget {
final Offset backCardOffset; final Offset backCardOffset;
const CardSwiper({ const CardSwiper({
Key? key,
required this.cardBuilder, required this.cardBuilder,
required this.cardsCount, required this.cardsCount,
Key? key,
this.controller, this.controller,
this.initialIndex = 0, this.initialIndex = 0,
this.padding = const EdgeInsets.symmetric(horizontal: 20, vertical: 25), this.padding = const EdgeInsets.symmetric(horizontal: 20, vertical: 25),

View File

@ -15,7 +15,6 @@ dependencies:
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_lints: ^2.0.1
screenshots: screenshots:
- description: "Example of the widget." - description: "Example of the widget."