From 5849c2e92665e3085a3342f88ebece2c39d98465 Mon Sep 17 00:00:00 2001 From: Neha Musale <70088044+Neha62-lit@users.noreply.github.com> Date: Fri, 8 Oct 2021 11:25:01 +0530 Subject: [PATCH] fix(lints): avoid_unnecessary_containers rule (#152) * fix(lints): avoid_unnecessary_containers rule * fix(lints): avoid_prints rule * fix(lints): Remove avoid_print and avoid_unnecessary_containers rules --- analysis_options.yaml | 5 --- lib/services/database_service.dart | 2 +- lib/services/local_storage_service.dart | 5 ++- .../about/about_privacy_policy_view.dart | 42 +++++++++---------- lib/ui/views/about/about_tos_view.dart | 36 ++++++++-------- lib/ui/views/groups/add_assignment_view.dart | 2 +- .../groups/components/assignment_card.dart | 2 +- .../views/groups/update_assignment_view.dart | 2 +- lib/ui/views/ib/ib_page_view.dart | 2 +- .../components/featured_project_card.dart | 18 ++++---- 10 files changed, 53 insertions(+), 63 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 3b3ebb78..18978f25 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -32,11 +32,6 @@ linter: directives_ordering: false - # In case of production should be set to true - avoid_print: false - - avoid_unnecessary_containers: false - prefer_if_elements_to_conditional_expressions: false avoid_function_literals_in_foreach_calls: false diff --git a/lib/services/database_service.dart b/lib/services/database_service.dart index 7f434fdd..92fffbd7 100644 --- a/lib/services/database_service.dart +++ b/lib/services/database_service.dart @@ -34,7 +34,7 @@ class DatabaseServiceImpl implements DatabaseService { try { await Hive.initFlutter(); } catch (e) { - print('Hive Initialization Failed'); + debugPrint('Hive Initialization Failed'); } // Register Adapters for Hive diff --git a/lib/services/local_storage_service.dart b/lib/services/local_storage_service.dart index 42530fba..398eea11 100644 --- a/lib/services/local_storage_service.dart +++ b/lib/services/local_storage_service.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'package:flutter/material.dart'; import 'package:mobile_app/enums/auth_type.dart'; import 'package:mobile_app/models/user.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -24,12 +25,12 @@ class LocalStorageService { dynamic _getFromDisk(String key) { var value = _preferences.get(key); - print('LocalStorageService:_getFromDisk. key: $key value: $value'); + debugPrint('LocalStorageService:_getFromDisk. key: $key value: $value'); return value; } void _saveToDisk(String key, T content) { - print('LocalStorageService:_saveToDisk. key: $key value: $content'); + debugPrint('LocalStorageService:_saveToDisk. key: $key value: $content'); if (content is String) { _preferences.setString(key, content); diff --git a/lib/ui/views/about/about_privacy_policy_view.dart b/lib/ui/views/about/about_privacy_policy_view.dart index 3a3a0e3c..5a1150d8 100644 --- a/lib/ui/views/about/about_privacy_policy_view.dart +++ b/lib/ui/views/about/about_privacy_policy_view.dart @@ -55,28 +55,26 @@ class AboutPrivacyPolicyView extends StatelessWidget { ? Theme.of(context).textTheme.headline5 : Theme.of(context).textTheme.headline6; - return Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - title != '' - ? Text( - title, - style: style.copyWith( - fontWeight: FontWeight.w400, - color: CVTheme.primaryHeading(context), - ), - textAlign: TextAlign.left, - ) - : Container(), - RichText( - textAlign: TextAlign.justify, - text: TextSpan( - children: content, - ), - ) - ], - ), + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + title != '' + ? Text( + title, + style: style.copyWith( + fontWeight: FontWeight.w400, + color: CVTheme.primaryHeading(context), + ), + textAlign: TextAlign.left, + ) + : Container(), + RichText( + textAlign: TextAlign.justify, + text: TextSpan( + children: content, + ), + ) + ], ); } diff --git a/lib/ui/views/about/about_tos_view.dart b/lib/ui/views/about/about_tos_view.dart index 304bfd53..cc3ab25b 100644 --- a/lib/ui/views/about/about_tos_view.dart +++ b/lib/ui/views/about/about_tos_view.dart @@ -50,26 +50,24 @@ class AboutTosView extends StatelessWidget { @required String title, @required List content, }) { - return Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - title, - style: Theme.of(context).textTheme.headline5.copyWith( - fontWeight: FontWeight.w400, - color: CVTheme.primaryHeading(context), - ), - textAlign: TextAlign.left, + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: Theme.of(context).textTheme.headline5.copyWith( + fontWeight: FontWeight.w400, + color: CVTheme.primaryHeading(context), + ), + textAlign: TextAlign.left, + ), + RichText( + textAlign: TextAlign.justify, + text: TextSpan( + children: content, ), - RichText( - textAlign: TextAlign.justify, - text: TextSpan( - children: content, - ), - ) - ], - ), + ) + ], ); } diff --git a/lib/ui/views/groups/add_assignment_view.dart b/lib/ui/views/groups/add_assignment_view.dart index beaa90c0..ed51f984 100644 --- a/lib/ui/views/groups/add_assignment_view.dart +++ b/lib/ui/views/groups/add_assignment_view.dart @@ -212,7 +212,7 @@ class _AddAssignmentViewState extends State { _descriptionEditorText = await _descriptionEditor.currentState.getText(); } on NoSuchMethodError { - print( + debugPrint( 'Handled html_editor error. NOTE: This should only throw during tests.'); _descriptionEditorText = ''; } diff --git a/lib/ui/views/groups/components/assignment_card.dart b/lib/ui/views/groups/components/assignment_card.dart index 2eedadda..cdfbf63f 100644 --- a/lib/ui/views/groups/components/assignment_card.dart +++ b/lib/ui/views/groups/components/assignment_card.dart @@ -116,7 +116,7 @@ class _AssignmentCardState extends State { ); } else { /// Add Not Submitted Button if _isProjectNotPresent & _isDeadlineOver - print('Not Submitted!'); + debugPrint('Not Submitted!'); } } else { if (_projectId != null) { diff --git a/lib/ui/views/groups/update_assignment_view.dart b/lib/ui/views/groups/update_assignment_view.dart index 8079a675..5c9a20cd 100644 --- a/lib/ui/views/groups/update_assignment_view.dart +++ b/lib/ui/views/groups/update_assignment_view.dart @@ -191,7 +191,7 @@ class _UpdateAssignmentViewState extends State { _descriptionEditorText = await _descriptionEditor.currentState.getText(); } on NoSuchMethodError { - print( + debugPrint( 'Handled html_editor error. NOTE: This should only throw during tests.'); _descriptionEditorText = ''; } diff --git a/lib/ui/views/ib/ib_page_view.dart b/lib/ui/views/ib/ib_page_view.dart index b9c310d0..d620fcab 100644 --- a/lib/ui/views/ib/ib_page_view.dart +++ b/lib/ui/views/ib/ib_page_view.dart @@ -88,7 +88,7 @@ class _IbPageViewState extends State { await _hideButtonController.scrollToIndex(_slugMap[slug], preferPosition: AutoScrollPosition.begin); } else { - print('[IB]: $slug not present in map'); + debugPrint('[IB]: $slug not present in map'); } } diff --git a/lib/ui/views/projects/components/featured_project_card.dart b/lib/ui/views/projects/components/featured_project_card.dart index aa37d007..c501ef01 100644 --- a/lib/ui/views/projects/components/featured_project_card.dart +++ b/lib/ui/views/projects/components/featured_project_card.dart @@ -61,16 +61,14 @@ class _FeaturedProjectCardState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( - child: Container( - child: Text( - widget.project.attributes.name, - maxLines: 1, - overflow: TextOverflow.ellipsis, - textAlign: TextAlign.start, - style: Theme.of(context).textTheme.headline6.copyWith( - color: CVTheme.textColor(context), - ), - ), + child: Text( + widget.project.attributes.name, + maxLines: 1, + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.start, + style: Theme.of(context).textTheme.headline6.copyWith( + color: CVTheme.textColor(context), + ), ), ), CVPrimaryButton(