Skip to content

Commit

Permalink
chore(lint): update lint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardodalarme committed Jan 9, 2024
1 parent 146ec76 commit b3ae883
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 29 deletions.
47 changes: 29 additions & 18 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
include: package:flutter_lints/flutter.yaml

analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true

errors:
annotate_overrides: error
avoid_shadowing_type_parameters: warning
exhaustive_cases: warning
literal_only_boolean_expressions: warning
missing_required_param: warning
missing_return: warning
no_duplicate_case_values: error
only_throw_errors: error
override_on_non_overriding_member: error
unnecessary_overrides: error
collection_methods_unrelated_type: warning
missing_required_param: error
missing_return: error
record_literal_one_positional_no_trailing_comma: error
unrelated_type_equality_checks: warning

linter:
rules:
- always_declare_return_types
- always_put_required_named_parameters_first
- always_use_package_imports
- annotate_overrides
- avoid_bool_literals_in_conditional_expressions
- avoid_catching_errors
- avoid_double_and_int_checks
- avoid_dynamic_calls
- avoid_empty_else
- avoid_equals_and_hash_code_on_mutable_classes
- avoid_escaping_inner_quotes
- avoid_field_initializers_in_const_classes
- avoid_final_parameters
- avoid_function_literals_in_foreach_calls
- avoid_implementing_value_types
- avoid_init_to_null
- avoid_js_rounded_ints
- avoid_multiple_declarations_per_line
- avoid_null_checks_in_equality_operators
- avoid_print
- avoid_private_typedef_functions
Expand All @@ -54,15 +56,16 @@ linter:
- cast_nullable_to_non_nullable
- close_sinks
- collection_methods_unrelated_type
- combinators_ordering
- comment_references
- conditional_uri_does_not_exist
- constant_identifier_names
- control_flow_in_finally
- curly_braces_in_flow_control_structures
- dangling_library_doc_comments
- depend_on_referenced_packages
- deprecated_consistency
- directives_ordering
- discarded_futures
- empty_catches
- empty_constructor_bodies
- empty_statements
Expand All @@ -71,29 +74,32 @@ linter:
- file_names
- hash_and_equals
- implementation_imports
- iterable_contains_unrelated_type
- implicit_call_tearoffs
- implicit_reopen
- invalid_case_patterns
- join_return_with_assignment
- leading_newlines_in_multiline_strings
- library_names
- library_prefixes
- library_private_types_in_public_api
- list_remove_unrelated_type
- literal_only_boolean_expressions
- matching_super_parameters
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
- no_duplicate_case_values
- no_leading_underscores_for_library_prefixes
- no_leading_underscores_for_local_identifiers
- no_literal_bool_comparisons
- no_logic_in_create_state
- no_runtimeType_toString
- no_wildcard_variable_uses
- non_constant_identifier_names
- noop_primitive_operations
- null_check_on_nullable_type_parameter
- null_closures
- omit_local_variable_types
- only_throw_errors
- overridden_fields
- package_api_docs
- package_names
- package_prefixed_library_names
- parameter_assignments
Expand Down Expand Up @@ -132,10 +138,12 @@ linter:
- provide_deprecation_message
- recursive_getters
- require_trailing_commas
- secure_pubspec_urls
- sized_box_for_whitespace
- sized_box_shrink_expand
- slash_for_doc_comments
- sort_child_properties_last
- sort_pub_dependencies
- sort_unnamed_constructors_first
- test_types_in_equals
- throw_in_finally
Expand All @@ -145,6 +153,7 @@ linter:
- unawaited_futures
- unnecessary_await_in_return
- unnecessary_brace_in_string_interps
- unnecessary_breaks
- unnecessary_const
- unnecessary_constructor_name
- unnecessary_getters_setters
Expand All @@ -171,15 +180,17 @@ linter:
- use_enums
- use_full_hex_values_for_flutter_colors
- use_function_type_syntax_for_parameters
- use_if_null_to_convert_nulls_to_bools
- use_is_even_rather_than_modulo
- use_key_in_widget_constructors
- use_late_for_private_fields_and_variables
- use_named_constants
- use_raw_strings
- use_rethrow_when_possible
- use_setters_to_change_properties
- use_string_buffers
- use_string_in_part_of_directives
- use_super_parameters
- use_test_throws_matchers
- use_to_and_as_if_applicable
- valid_regexps
- void_checks
8 changes: 4 additions & 4 deletions example/lib/example_candidate_model.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:flutter/cupertino.dart';

class ExampleCandidateModel {
String name;
String job;
String city;
List<Color> color;
final String name;
final String job;
final String city;
final List<Color> color;

ExampleCandidateModel({
required this.name,
Expand Down
7 changes: 3 additions & 4 deletions example/lib/example_card.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:example/example_candidate_model.dart';
import 'package:flutter/material.dart';

import 'example_candidate_model.dart';

class ExampleCard extends StatelessWidget {
final ExampleCandidateModel candidate;

Expand All @@ -23,7 +22,7 @@ class ExampleCard extends StatelessWidget {
spreadRadius: 3,
blurRadius: 7,
offset: const Offset(0, 3),
)
),
],
),
alignment: Alignment.center,
Expand Down Expand Up @@ -66,7 +65,7 @@ class ExampleCard extends StatelessWidget {
Text(
candidate.city,
style: const TextStyle(color: Colors.grey),
)
),
],
),
),
Expand Down
3 changes: 2 additions & 1 deletion lib/src/card_animation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ class CardAnimation {
void updateDifference() {
final discrepancy = (total / 10).abs();

var diffX = 0.0, diffY = 0.0;
var diffX = 0.0;
var diffY = 0.0;

if (initialOffset.dx > 0) {
diffX = discrepancy;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/card_swiper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ class CardSwiper extends StatefulWidget {
final Offset backCardOffset;

const CardSwiper({
Key? key,
required this.cardBuilder,
required this.cardsCount,
Key? key,
this.controller,
this.initialIndex = 0,
this.padding = const EdgeInsets.symmetric(horizontal: 20, vertical: 25),
Expand Down
1 change: 0 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.1

screenshots:
- description: "Example of the widget."
Expand Down

0 comments on commit b3ae883

Please sign in to comment.