From 2a05764f09b364568da6fbcb9e584e738a264b20 Mon Sep 17 00:00:00 2001 From: Saeed Masoumi <7masoumi@gmail.com> Date: Tue, 4 Jun 2019 16:00:04 +0430 Subject: [PATCH 1/9] Use isEmpty instead of length --- analysis_options.yaml | 27 +++++++++++++++++++ .../chart/bar_chart/bar_chart_painter.dart | 2 +- lib/src/chart/line_chart/line_chart_data.dart | 2 +- .../chart/line_chart/line_chart_painter.dart | 2 +- .../chart/pie_chart/pie_chart_painter.dart | 2 +- 5 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 analysis_options.yaml diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 000000000..9aa7153e7 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,27 @@ +linter: + rules: + - avoid_empty_else + - avoid_init_to_null + - avoid_relative_lib_imports + - avoid_return_types_on_setters + - avoid_shadowing_type_parameters + - avoid_types_as_parameter_names + - curly_braces_in_flow_control_structures + - empty_catches + - empty_constructor_bodies + - library_names + - library_prefixes + - no_duplicate_case_values + - null_closures + - prefer_contains + - prefer_equal_for_default_values + - prefer_is_empty + - prefer_is_not_empty + - recursive_getters + - slash_for_doc_comments + - type_init_formals + - unawaited_futures + - unnecessary_null_in_if_null_operators + - unrelated_type_equality_checks + - use_rethrow_when_possible + - valid_regexps \ No newline at end of file diff --git a/lib/src/chart/bar_chart/bar_chart_painter.dart b/lib/src/chart/bar_chart/bar_chart_painter.dart index 06ca7829b..43679278e 100644 --- a/lib/src/chart/bar_chart/bar_chart_painter.dart +++ b/lib/src/chart/bar_chart/bar_chart_painter.dart @@ -19,7 +19,7 @@ class BarChartPainter extends FlAxisChartPainter { void paint(Canvas canvas, Size viewSize) { super.paint(canvas, viewSize); - if (data.barGroups.length == 0) { + if (data.barGroups.isEmpty) { return; } diff --git a/lib/src/chart/line_chart/line_chart_data.dart b/lib/src/chart/line_chart/line_chart_data.dart index 4590c1c57..94ff768a2 100644 --- a/lib/src/chart/line_chart/line_chart_data.dart +++ b/lib/src/chart/line_chart/line_chart_data.dart @@ -39,7 +39,7 @@ class LineChartData extends FlAxisChartData { throw Exception("spots could not be null or empty"); } }); - if (lineBarsData.length > 0) { + if (lineBarsData.isNotEmpty) { var canModifyMinX = false; if (minX == null) { minX = lineBarsData[0].spots[0].x; diff --git a/lib/src/chart/line_chart/line_chart_painter.dart b/lib/src/chart/line_chart/line_chart_painter.dart index 97f15c12a..ddd5c8281 100644 --- a/lib/src/chart/line_chart/line_chart_painter.dart +++ b/lib/src/chart/line_chart/line_chart_painter.dart @@ -30,7 +30,7 @@ class LineChartPainter extends FlAxisChartPainter { @override void paint(Canvas canvas, Size viewSize) { super.paint(canvas, viewSize); - if (data.lineBarsData.length == 0) { + if (data.lineBarsData.isEmpty) { return; } diff --git a/lib/src/chart/pie_chart/pie_chart_painter.dart b/lib/src/chart/pie_chart/pie_chart_painter.dart index a57943d8f..130906950 100644 --- a/lib/src/chart/pie_chart/pie_chart_painter.dart +++ b/lib/src/chart/pie_chart/pie_chart_painter.dart @@ -37,7 +37,7 @@ class PieChartPainter extends FlChartPainter { @override void paint(Canvas canvas, Size viewSize) { super.paint(canvas, viewSize); - if (data.sections.length == 0) { + if (data.sections.isEmpty) { return; } From c64850ed683c0c8906cd5c9ec74c11f5e7ccaf3e Mon Sep 17 00:00:00 2001 From: Saeed Masoumi <7masoumi@gmail.com> Date: Tue, 4 Jun 2019 16:13:31 +0430 Subject: [PATCH 2/9] Add flutter analysis_options.yaml --- analysis_options.yaml | 143 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 138 insertions(+), 5 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 9aa7153e7..3c24e9230 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,27 +1,160 @@ +analyzer: + strong-mode: + implicit-dynamic: false + errors: + # treat missing required parameters as a warning (not a hint) + missing_required_param: warning + # treat missing returns as a warning (not a hint) + missing_return: warning + # allow having TODOs in the code + todo: ignore + # Ignore analyzer hints for updating pubspecs when using Future or + # Stream and not importing dart:async + # Please see https://github.com/flutter/flutter/pull/24528 for details. + sdk_version_async_exported_from_core: ignore + exclude: + - 'bin/cache/**' + # the following two are relative to the stocks example and the flutter package respectively + # see https://github.com/dart-lang/sdk/issues/28463 + - 'lib/i18n/stock_messages_*.dart' + - 'lib/src/http/**' + linter: rules: + # these rules are documented on and in the same order as + # the Dart Lint rules page to make maintenance easier + # https://github.com/dart-lang/linter/blob/master/example/all.yaml + - always_declare_return_types + - always_put_control_body_on_new_line + # - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219 + - always_require_non_null_named_parameters + - always_specify_types + - annotate_overrides + # - avoid_annotating_with_dynamic # conflicts with always_specify_types + - avoid_as + # - avoid_bool_literals_in_conditional_expressions # not yet tested + # - avoid_catches_without_on_clauses # we do this commonly + # - avoid_catching_errors # we do this commonly + - avoid_classes_with_only_static_members + # - avoid_double_and_int_checks # only useful when targeting JS runtime - avoid_empty_else + - avoid_field_initializers_in_const_classes + - avoid_function_literals_in_foreach_calls + # - avoid_implementing_value_types # not yet tested - avoid_init_to_null + # - avoid_js_rounded_ints # only useful when targeting JS runtime + - avoid_null_checks_in_equality_operators + # - avoid_positional_boolean_parameters # not yet tested + # - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356) - avoid_relative_lib_imports + - avoid_renaming_method_parameters - avoid_return_types_on_setters - - avoid_shadowing_type_parameters + # - avoid_returning_null # there are plenty of valid reasons to return null + # - avoid_returning_null_for_future # not yet tested + - avoid_returning_null_for_void + # - avoid_returning_this # there are plenty of valid reasons to return this + # - avoid_setters_without_getters # not yet tested + # - avoid_shadowing_type_parameters # not yet tested + # - avoid_single_cascade_in_expression_statements # not yet tested + - avoid_slow_async_io - avoid_types_as_parameter_names - - curly_braces_in_flow_control_structures + # - avoid_types_on_closure_parameters # conflicts with always_specify_types + - avoid_unused_constructor_parameters + - avoid_void_async + - await_only_futures + - camel_case_types + - cancel_subscriptions + # - cascade_invocations # not yet tested + # - close_sinks # not reliable enough + # - comment_references # blocked on https://github.com/flutter/flutter/issues/20765 + # - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204 + - control_flow_in_finally + # - curly_braces_in_flow_control_structures # not yet tested + - directives_ordering - empty_catches - empty_constructor_bodies + - empty_statements + # - file_names # not yet tested + - flutter_style_todos + - hash_and_equals + - implementation_imports + # - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811 + - iterable_contains_unrelated_type + # - join_return_with_assignment # not yet tested - library_names - library_prefixes + # - lines_longer_than_80_chars # not yet tested + - list_remove_unrelated_type + # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181 + - no_adjacent_strings_in_list - no_duplicate_case_values - - null_closures + - non_constant_identifier_names + # - null_closures # not yet tested + # - omit_local_variable_types # opposite of always_specify_types + # - one_member_abstracts # too many false positives + # - only_throw_errors # https://github.com/flutter/flutter/issues/5792 + - overridden_fields + - package_api_docs + - package_names + - package_prefixed_library_names + # - parameter_assignments # we do this commonly + - prefer_adjacent_string_concatenation + - prefer_asserts_in_initializer_lists + - prefer_collection_literals + - prefer_conditional_assignment + - prefer_const_constructors + - prefer_const_constructors_in_immutables + - prefer_const_declarations + - prefer_const_literals_to_create_immutables + # - prefer_constructors_over_static_methods # not yet tested - prefer_contains - prefer_equal_for_default_values + # - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods + - prefer_final_fields + - prefer_final_locals + - prefer_foreach + # - prefer_function_declarations_over_variables # not yet tested + - prefer_generic_function_type_aliases + - prefer_initializing_formals + # - prefer_int_literals # not yet tested + # - prefer_interpolation_to_compose_strings # not yet tested - prefer_is_empty - prefer_is_not_empty + - prefer_iterable_whereType + # - prefer_mixin # https://github.com/dart-lang/language/issues/32 + # - prefer_null_aware_operators # disable until NNBD, see https://github.com/flutter/flutter/pull/32711#issuecomment-492930932 + - prefer_single_quotes + - prefer_typing_uninitialized_variables + - prefer_void_to_null + # - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml - recursive_getters - slash_for_doc_comments + - sort_constructors_first + - sort_pub_dependencies + - sort_unnamed_constructors_first + # - super_goes_last # no longer needed w/ Dart 2 + - test_types_in_equals + - throw_in_finally + # - type_annotate_public_apis # subset of always_specify_types - type_init_formals - - unawaited_futures + # - unawaited_futures # too many false positives + # - unnecessary_await_in_return # not yet tested + - unnecessary_brace_in_string_interps + - unnecessary_const + - unnecessary_getters_setters + # - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498 + - unnecessary_new + - unnecessary_null_aware_assignments - unnecessary_null_in_if_null_operators + - unnecessary_overrides + - unnecessary_parenthesis + - unnecessary_statements + - unnecessary_this - unrelated_type_equality_checks + # - use_function_type_syntax_for_parameters # not yet tested - use_rethrow_when_possible - - valid_regexps \ No newline at end of file + # - use_setters_to_change_properties # not yet tested + # - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182 + # - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review + - valid_regexps + # - void_checks # not yet tested \ No newline at end of file From a0ead7a591ce3ed81831caf04175bcf4f56722d5 Mon Sep 17 00:00:00 2001 From: Saeed Masoumi <7masoumi@gmail.com> Date: Tue, 4 Jun 2019 16:14:17 +0430 Subject: [PATCH 3/9] Replace isEmpty instead of length --- lib/src/chart/bar_chart/bar_chart_data.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/chart/bar_chart/bar_chart_data.dart b/lib/src/chart/bar_chart/bar_chart_data.dart index 1b3769fb9..5880f1f18 100644 --- a/lib/src/chart/bar_chart/bar_chart_data.dart +++ b/lib/src/chart/bar_chart/bar_chart_data.dart @@ -49,7 +49,7 @@ class BarChartData extends FlAxisChartData { } }); - if (barGroups.length > 0) { + if (barGroups.isNotEmpty) { var canModifyMinX = false; if (minX == null) { minX = barGroups[0].x.toDouble(); @@ -150,7 +150,7 @@ class BarChartGroupData { /// calculates the whole width of our group, /// by adding all rod's width and group space * rods count. double get width { - if (barRods.length == 0) { + if (barRods.isEmpty) { return 0; } From b78d332a76c62cd1a0fca985cef2517697c53da2 Mon Sep 17 00:00:00 2001 From: Saeed Masoumi <7masoumi@gmail.com> Date: Tue, 4 Jun 2019 16:23:36 +0430 Subject: [PATCH 4/9] Remove unnecessary new keywords --- lib/src/chart/bar_chart/bar_chart_painter.dart | 10 +++++----- .../base/fl_axis_chart/fl_axis_chart_painter.dart | 2 +- lib/src/chart/line_chart/line_chart_painter.dart | 10 +++++----- lib/src/chart/pie_chart/pie_chart_painter.dart | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/src/chart/bar_chart/bar_chart_painter.dart b/lib/src/chart/bar_chart/bar_chart_painter.dart index 43679278e..854d11029 100644 --- a/lib/src/chart/bar_chart/bar_chart_painter.dart +++ b/lib/src/chart/bar_chart/bar_chart_painter.dart @@ -199,13 +199,13 @@ class BarChartPainter extends FlAxisChartPainter { String text = data.titlesData.getVerticalTitles(data.gridData.verticalInterval * verticalCounter); - TextSpan span = new TextSpan(style: data.titlesData.verticalTitlesTextStyle, text: text); - TextPainter tp = new TextPainter( + TextSpan span = TextSpan(style: data.titlesData.verticalTitlesTextStyle, text: text); + TextPainter tp = TextPainter( text: span, textAlign: TextAlign.center, textDirection: TextDirection.ltr); tp.layout(maxWidth: getExtraNeededHorizontalSpace()); x -= tp.width + data.titlesData.verticalTitleMargin; y -= (tp.height / 2); - tp.paint(canvas, new Offset(x, y)); + tp.paint(canvas, Offset(x, y)); verticalCounter++; } @@ -215,8 +215,8 @@ class BarChartPainter extends FlAxisChartPainter { groupsX.asMap().forEach((int index, double x) { String text = data.titlesData.getHorizontalTitles(index.toDouble()); - TextSpan span = new TextSpan(style: data.titlesData.horizontalTitlesTextStyle, text: text); - TextPainter tp = new TextPainter( + TextSpan span = TextSpan(style: data.titlesData.horizontalTitlesTextStyle, text: text); + TextPainter tp = TextPainter( text: span, textAlign: TextAlign.center, textDirection: TextDirection.ltr); tp.layout(); diff --git a/lib/src/chart/base/fl_axis_chart/fl_axis_chart_painter.dart b/lib/src/chart/base/fl_axis_chart/fl_axis_chart_painter.dart index fd8728323..01e49f6e7 100644 --- a/lib/src/chart/base/fl_axis_chart/fl_axis_chart_painter.dart +++ b/lib/src/chart/base/fl_axis_chart/fl_axis_chart_painter.dart @@ -12,7 +12,7 @@ abstract class FlAxisChartPainter extends FlChartPain Paint gridPaint; FlAxisChartPainter(this.data) : super(data) { - gridPaint = new Paint()..style = PaintingStyle.fill; + gridPaint = Paint()..style = PaintingStyle.fill; } @override diff --git a/lib/src/chart/line_chart/line_chart_painter.dart b/lib/src/chart/line_chart/line_chart_painter.dart index ddd5c8281..a07525ed8 100644 --- a/lib/src/chart/line_chart/line_chart_painter.dart +++ b/lib/src/chart/line_chart/line_chart_painter.dart @@ -245,13 +245,13 @@ class LineChartPainter extends FlAxisChartPainter { String text = data.titlesData.getVerticalTitles(data.gridData.verticalInterval * verticalCounter); - TextSpan span = new TextSpan(style: data.titlesData.verticalTitlesTextStyle, text: text); - TextPainter tp = new TextPainter( + TextSpan span = TextSpan(style: data.titlesData.verticalTitlesTextStyle, text: text); + TextPainter tp = TextPainter( text: span, textAlign: TextAlign.center, textDirection: TextDirection.ltr); tp.layout(maxWidth: getExtraNeededHorizontalSpace()); x -= tp.width + data.titlesData.verticalTitleMargin; y -= (tp.height / 2); - tp.paint(canvas, new Offset(x, y)); + tp.paint(canvas, Offset(x, y)); verticalCounter++; } @@ -267,8 +267,8 @@ class LineChartPainter extends FlAxisChartPainter { String text = data.titlesData .getHorizontalTitles(data.gridData.horizontalInterval * horizontalCounter); - TextSpan span = new TextSpan(style: data.titlesData.horizontalTitlesTextStyle, text: text); - TextPainter tp = new TextPainter( + TextSpan span = TextSpan(style: data.titlesData.horizontalTitlesTextStyle, text: text); + TextPainter tp = TextPainter( text: span, textAlign: TextAlign.center, textDirection: TextDirection.ltr); tp.layout(); diff --git a/lib/src/chart/pie_chart/pie_chart_painter.dart b/lib/src/chart/pie_chart/pie_chart_painter.dart index 130906950..79a300620 100644 --- a/lib/src/chart/pie_chart/pie_chart_painter.dart +++ b/lib/src/chart/pie_chart/pie_chart_painter.dart @@ -54,7 +54,7 @@ class PieChartPainter extends FlChartPainter { } void drawSections(Canvas canvas, Size viewSize) { - canvas.saveLayer(Rect.fromLTWH(0, 0, viewSize.width, viewSize.height), new Paint()); + canvas.saveLayer(Rect.fromLTWH(0, 0, viewSize.width, viewSize.height), Paint()); Offset center = Offset(viewSize.width / 2, viewSize.height / 2); double tempAngle = data.startDegreeOffset; @@ -136,8 +136,8 @@ class PieChartPainter extends FlChartPainter { ); if (section.showTitle) { - TextSpan span = new TextSpan(style: section.titleStyle, text: section.title); - TextPainter tp = new TextPainter( + TextSpan span = TextSpan(style: section.titleStyle, text: section.title); + TextPainter tp = TextPainter( text: span, textAlign: TextAlign.center, textDirection: TextDirection.ltr); tp.layout(); tp.paint(canvas, sectionCenterOffset - Offset(tp.width / 2, tp.height / 2)); From e314bb0aa3f77dec8b07ad31dbfe6cc518c392a9 Mon Sep 17 00:00:00 2001 From: Saeed Masoumi <7masoumi@gmail.com> Date: Tue, 4 Jun 2019 16:35:04 +0430 Subject: [PATCH 5/9] Use ??= --- analysis_options.yaml | 1 - lib/src/chart/base/fl_chart/fl_chart_data.dart | 8 ++------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 3c24e9230..3d4dbd311 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -28,7 +28,6 @@ linter: - always_put_control_body_on_new_line # - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219 - always_require_non_null_named_parameters - - always_specify_types - annotate_overrides # - avoid_annotating_with_dynamic # conflicts with always_specify_types - avoid_as diff --git a/lib/src/chart/base/fl_chart/fl_chart_data.dart b/lib/src/chart/base/fl_chart/fl_chart_data.dart index 30abe57ee..7ecd6c2db 100644 --- a/lib/src/chart/base/fl_chart/fl_chart_data.dart +++ b/lib/src/chart/base/fl_chart/fl_chart_data.dart @@ -11,9 +11,7 @@ class FlChartData { FlChartData({ this.borderData, }) { - if (borderData == null) { - borderData = FlBorderData(); - } + borderData ??= FlBorderData(); } } @@ -28,13 +26,11 @@ class FlBorderData { this.show = true, this.border, }) { - if (border == null) { - border = Border.all( + border ??= Border.all( color: Colors.black, width: 1.0, style: BorderStyle.solid, ); - } } } From 5bc647c55373fb8129b9bbd5c4c8df3fc1918627 Mon Sep 17 00:00:00 2001 From: Saeed Masoumi <7masoumi@gmail.com> Date: Tue, 4 Jun 2019 16:38:57 +0430 Subject: [PATCH 6/9] Use single quotes --- lib/fl_chart_widget.dart | 2 +- lib/src/chart/bar_chart/bar_chart_data.dart | 4 ++-- lib/src/chart/base/fl_chart/fl_chart_data.dart | 2 +- lib/src/chart/line_chart/line_chart_data.dart | 4 ++-- lib/src/chart/pie_chart/pie_chart_data.dart | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/fl_chart_widget.dart b/lib/fl_chart_widget.dart index 5e8ff4458..a3d908611 100644 --- a/lib/fl_chart_widget.dart +++ b/lib/fl_chart_widget.dart @@ -27,7 +27,7 @@ class FlChartWidget extends StatefulWidget { @required this.flChart, }) : super(key: key) { if (flChart == null) { - throw Exception("flChart might not be null"); + throw Exception('flChart might not be null'); } } diff --git a/lib/src/chart/bar_chart/bar_chart_data.dart b/lib/src/chart/bar_chart/bar_chart_data.dart index 5880f1f18..3815579cb 100644 --- a/lib/src/chart/bar_chart/bar_chart_data.dart +++ b/lib/src/chart/bar_chart/bar_chart_data.dart @@ -44,8 +44,8 @@ class BarChartData extends FlAxisChartData { double maxY, ) { barGroups.forEach((barData) { - if (barData.barRods == null || barData.barRods.length <= 0) { - throw Exception("barRods could not be null or empty"); + if (barData.barRods == null || barData.barRods.isEmpty) { + throw Exception('barRods could not be null or empty'); } }); diff --git a/lib/src/chart/base/fl_chart/fl_chart_data.dart b/lib/src/chart/base/fl_chart/fl_chart_data.dart index 7ecd6c2db..c7cb1911a 100644 --- a/lib/src/chart/base/fl_chart/fl_chart_data.dart +++ b/lib/src/chart/base/fl_chart/fl_chart_data.dart @@ -42,7 +42,7 @@ class FlBorderData { typedef GetTitleFunction = String Function(double value); String defaultGetTitle(double value) { - return "${value.toInt()}"; + return '${value.toInt()}'; } /// This class is responsible to hold data about showing titles. diff --git a/lib/src/chart/line_chart/line_chart_data.dart b/lib/src/chart/line_chart/line_chart_data.dart index 94ff768a2..6f50b8666 100644 --- a/lib/src/chart/line_chart/line_chart_data.dart +++ b/lib/src/chart/line_chart/line_chart_data.dart @@ -35,8 +35,8 @@ class LineChartData extends FlAxisChartData { double maxY, ) { lineBarsData.forEach((lineBarChart) { - if (lineBarChart.spots == null || lineBarChart.spots.length <= 0) { - throw Exception("spots could not be null or empty"); + if (lineBarChart.spots == null || lineBarChart.spots.isEmpty) { + throw Exception('spots could not be null or empty'); } }); if (lineBarsData.isNotEmpty) { diff --git a/lib/src/chart/pie_chart/pie_chart_data.dart b/lib/src/chart/pie_chart/pie_chart_data.dart index 6b6b0f558..592f2d621 100644 --- a/lib/src/chart/pie_chart/pie_chart_data.dart +++ b/lib/src/chart/pie_chart/pie_chart_data.dart @@ -68,7 +68,7 @@ class PieChartSectionData { this.showTitle = true, this.titleStyle = const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold), - this.title = "1", + this.title = '1', this.titlePositionPercentageOffset = 0.5, }); } From a9b569315c9fb400dab99ccee1dc22055451b0ed Mon Sep 17 00:00:00 2001 From: Saeed Masoumi <7masoumi@gmail.com> Date: Tue, 4 Jun 2019 16:40:41 +0430 Subject: [PATCH 7/9] Use parent field name in paint method --- lib/src/chart/base/fl_chart/fl_chart_painter.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/chart/base/fl_chart/fl_chart_painter.dart b/lib/src/chart/base/fl_chart/fl_chart_painter.dart index 42f5fb9e7..580f43324 100644 --- a/lib/src/chart/base/fl_chart/fl_chart_painter.dart +++ b/lib/src/chart/base/fl_chart/fl_chart_painter.dart @@ -21,8 +21,8 @@ abstract class FlChartPainter extends CustomPainter { } @override - void paint(Canvas canvas, Size viewSize) { - drawViewBorder(canvas, viewSize); + void paint(Canvas canvas, Size size) { + drawViewBorder(canvas, size); } void drawViewBorder(Canvas canvas, Size viewSize) { From 7e0a36299515ddde684c7088a9893f50f4716a10 Mon Sep 17 00:00:00 2001 From: Saeed Masoumi <7masoumi@gmail.com> Date: Tue, 4 Jun 2019 17:13:32 +0430 Subject: [PATCH 8/9] Use @override annotation --- lib/src/chart/bar_chart/bar_chart_painter.dart | 11 ++++++----- .../base/fl_axis_chart/fl_axis_chart_painter.dart | 6 +++--- lib/src/chart/line_chart/line_chart_painter.dart | 1 + lib/src/chart/pie_chart/pie_chart_painter.dart | 12 ++++++------ 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/src/chart/bar_chart/bar_chart_painter.dart b/lib/src/chart/bar_chart/bar_chart_painter.dart index 854d11029..cd2cef920 100644 --- a/lib/src/chart/bar_chart/bar_chart_painter.dart +++ b/lib/src/chart/bar_chart/bar_chart_painter.dart @@ -16,16 +16,16 @@ class BarChartPainter extends FlAxisChartPainter { } @override - void paint(Canvas canvas, Size viewSize) { - super.paint(canvas, viewSize); + void paint(Canvas canvas, Size size) { + super.paint(canvas, size); if (data.barGroups.isEmpty) { return; } - List groupsX = calculateGroupsX(viewSize, data.barGroups, data.alignment); - drawBars(canvas, viewSize, groupsX); - drawTitles(canvas, viewSize, groupsX); + List groupsX = calculateGroupsX(size, data.barGroups, data.alignment); + drawBars(canvas, size, groupsX); + drawTitles(canvas, size, groupsX); } /// this method calculates the x of our showing groups, @@ -259,6 +259,7 @@ class BarChartPainter extends FlAxisChartPainter { /// calculate left offset for draw the chart, /// maybe we want to show both left and right titles, /// then just the left titles will effect on this function. + @override double getLeftOffsetDrawSize() { double parentNeeded = super.getLeftOffsetDrawSize(); if (data.titlesData.show && data.titlesData.showVerticalTitles) { diff --git a/lib/src/chart/base/fl_axis_chart/fl_axis_chart_painter.dart b/lib/src/chart/base/fl_axis_chart/fl_axis_chart_painter.dart index 01e49f6e7..a9080b0ec 100644 --- a/lib/src/chart/base/fl_axis_chart/fl_axis_chart_painter.dart +++ b/lib/src/chart/base/fl_axis_chart/fl_axis_chart_painter.dart @@ -16,9 +16,9 @@ abstract class FlAxisChartPainter extends FlChartPain } @override - void paint(Canvas canvas, Size viewSize) { - super.paint(canvas, viewSize); - drawGrid(canvas, viewSize); + void paint(Canvas canvas, Size size) { + super.paint(canvas, size); + drawGrid(canvas, size); } void drawGrid(Canvas canvas, Size viewSize) { diff --git a/lib/src/chart/line_chart/line_chart_painter.dart b/lib/src/chart/line_chart/line_chart_painter.dart index a07525ed8..99224c4f3 100644 --- a/lib/src/chart/line_chart/line_chart_painter.dart +++ b/lib/src/chart/line_chart/line_chart_painter.dart @@ -313,6 +313,7 @@ class LineChartPainter extends FlAxisChartPainter { /// calculate left offset for draw the chart, /// maybe we want to show both left and right titles, /// then just the left titles will effect on this function. + @override double getLeftOffsetDrawSize() { double parentNeeded = super.getLeftOffsetDrawSize(); if (data.titlesData.show && data.titlesData.showVerticalTitles) { diff --git a/lib/src/chart/pie_chart/pie_chart_painter.dart b/lib/src/chart/pie_chart/pie_chart_painter.dart index 79a300620..4d6a0c5b0 100644 --- a/lib/src/chart/pie_chart/pie_chart_painter.dart +++ b/lib/src/chart/pie_chart/pie_chart_painter.dart @@ -26,7 +26,7 @@ class PieChartPainter extends FlChartPainter { sectionsSpaceClearPaint = Paint() ..style = PaintingStyle.fill - ..color = Color(0x000000000) + ..color = const Color(0x000000000) ..blendMode = BlendMode.srcOut; centerSpacePaint = Paint() @@ -35,15 +35,15 @@ class PieChartPainter extends FlChartPainter { } @override - void paint(Canvas canvas, Size viewSize) { - super.paint(canvas, viewSize); + void paint(Canvas canvas, Size size) { + super.paint(canvas, size); if (data.sections.isEmpty) { return; } - drawCenterSpace(canvas, viewSize); - drawSections(canvas, viewSize); - drawTexts(canvas, viewSize); + drawCenterSpace(canvas, size); + drawSections(canvas, size); + drawTexts(canvas, size); } void drawCenterSpace(Canvas canvas, Size viewSize) { From cf852fac1e55600ba51e4bdf410b92d8b929fd66 Mon Sep 17 00:00:00 2001 From: Saeed Masoumi <7masoumi@gmail.com> Date: Tue, 4 Jun 2019 17:15:37 +0430 Subject: [PATCH 9/9] Remove sort_constructors_first --- analysis_options.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 3d4dbd311..cc8986c7e 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -128,9 +128,7 @@ linter: # - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml - recursive_getters - slash_for_doc_comments - - sort_constructors_first - sort_pub_dependencies - - sort_unnamed_constructors_first # - super_goes_last # no longer needed w/ Dart 2 - test_types_in_equals - throw_in_finally