diff --git a/contact/pubspec.yaml b/contact/pubspec.yaml index dedb11a6e..33b10417d 100644 --- a/contact/pubspec.yaml +++ b/contact/pubspec.yaml @@ -28,7 +28,8 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^1.0.0 + + flutter_lints: 1.0.4 build_runner: 2.1.11 diff --git a/core/analysis_options.yaml b/core/analysis_options.yaml new file mode 100644 index 000000000..61b6c4de1 --- /dev/null +++ b/core/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/core/lib/core.dart b/core/lib/core.dart index 2c90072fb..6247f20f5 100644 --- a/core/lib/core.dart +++ b/core/lib/core.dart @@ -104,12 +104,6 @@ export 'presentation/state/success.dart'; export 'presentation/state/failure.dart'; export 'presentation/state/app_state.dart'; -// Local -export 'data/local/config/database_config.dart'; -export 'data/local/config/email_address_table.dart'; -export 'data/local/database_client.dart'; -export 'data/local/database_manager.dart'; - // Model export 'data/model/source_type/data_source_type.dart'; export 'data/model/query/query_parameter.dart'; \ No newline at end of file diff --git a/core/lib/data/extensions/options_extensions.dart b/core/lib/data/extensions/options_extensions.dart index f20e898c1..7c252cd19 100644 --- a/core/lib/data/extensions/options_extensions.dart +++ b/core/lib/data/extensions/options_extensions.dart @@ -2,10 +2,10 @@ import 'package:dio/dio.dart'; extension OptionsExtension on Options { Options appendHeaders(Map additionalHeaders) { - if (this.headers != null) { - this.headers?.addAll(additionalHeaders); + if (headers != null) { + headers?.addAll(additionalHeaders); } else { - this.headers = additionalHeaders; + headers = additionalHeaders; } return this; } diff --git a/core/lib/data/network/download/download_manager.dart b/core/lib/data/network/download/download_manager.dart index a12e0df21..a6a27cd44 100644 --- a/core/lib/data/network/download/download_manager.dart +++ b/core/lib/data/network/download/download_manager.dart @@ -75,7 +75,7 @@ class DownloadManager { await streamController.close(); return streamController.stream.first; } else { - throw exception; + rethrow; } } return streamController.stream.first; @@ -100,7 +100,7 @@ class DownloadManager { html.Url.revokeObjectUrl(url); } catch (exception) { log('DownloadManager::createAnchorElementDownloadFileWeb(): ERROR: $exception'); - throw exception; + rethrow; } } diff --git a/core/lib/data/utils/compress_file_utils.dart b/core/lib/data/utils/compress_file_utils.dart index 6f43766cb..8e177fa00 100644 --- a/core/lib/data/utils/compress_file_utils.dart +++ b/core/lib/data/utils/compress_file_utils.dart @@ -14,7 +14,7 @@ class CompressFileUtils { static const int MAX_IMAGE_WIDTH = 1000; bool _exceedMaximumImageSize(Uint8List bytesData) { - final maximumSizeBytes = MAXIMUM_IMAGE_SIZE_KB * 1024; + const maximumSizeBytes = MAXIMUM_IMAGE_SIZE_KB * 1024; final sizeBytesData = bytesData.length; log('CompressFileUtils::exceedMaximumImageSize(): maximumSizeBytes: $maximumSizeBytes'); log('CompressFileUtils::exceedMaximumImageSize(): sizeBytesData: $sizeBytesData'); diff --git a/core/lib/domain/exceptions/remote_exception.dart b/core/lib/domain/exceptions/remote_exception.dart index 1bbdb35d7..0d1c4a631 100644 --- a/core/lib/domain/exceptions/remote_exception.dart +++ b/core/lib/domain/exceptions/remote_exception.dart @@ -2,23 +2,23 @@ import 'package:equatable/equatable.dart'; abstract class RemoteException extends Equatable implements Exception { - static final connectError = 'Connect error'; + static const connectError = 'Connect error'; final String? message; final int? code; - RemoteException({this.code, this.message}); + const RemoteException({this.code, this.message}); } class UnknownError extends RemoteException { - UnknownError({int? code, String? message}) : super(code: code, message: message); + const UnknownError({int? code, String? message}) : super(code: code, message: message); @override List get props => []; } class ConnectError extends RemoteException { - ConnectError() : super(message: RemoteException.connectError); + const ConnectError() : super(message: RemoteException.connectError); @override List get props => []; diff --git a/core/lib/domain/extensions/datetime_extension.dart b/core/lib/domain/extensions/datetime_extension.dart index 55afce40e..8f2d6831f 100644 --- a/core/lib/domain/extensions/datetime_extension.dart +++ b/core/lib/domain/extensions/datetime_extension.dart @@ -3,17 +3,17 @@ extension DateTimeExtension on DateTime { bool isToday() { final now = DateTime.now(); - return now.day == this.day && now.month == this.month && now.year == this.year; + return now.day == day && now.month == month && now.year == year; } bool isYesterday() { - final yesterday = DateTime.now().subtract(Duration(days: 1)); - return yesterday.day == this.day && yesterday.month == this.month && yesterday.year == this.year; + final yesterday = DateTime.now().subtract(const Duration(days: 1)); + return yesterday.day == day && yesterday.month == month && yesterday.year == year; } bool isThisYear() { final now = DateTime.now(); - return now.year == this.year; + return now.year == year; } int daysBetween(DateTime from) { diff --git a/core/lib/presentation/extensions/capitalize_extension.dart b/core/lib/presentation/extensions/capitalize_extension.dart index 65d74dfc9..6289213ab 100644 --- a/core/lib/presentation/extensions/capitalize_extension.dart +++ b/core/lib/presentation/extensions/capitalize_extension.dart @@ -1,6 +1,6 @@ extension CapitalizeExtension on String { - String get inCaps => this.length > 0 ?'${this[0].toUpperCase()}${this.toLowerCase().substring(1)}':''; - String get allInCaps => this.toUpperCase(); - String get capitalizeFirstEach => this.replaceAll(RegExp(' +'), ' ').split(" ").map((str) => str.inCaps).join(" "); + String get inCaps => length > 0 ?'${this[0].toUpperCase()}${toLowerCase().substring(1)}':''; + String get allInCaps => toUpperCase(); + String get capitalizeFirstEach => replaceAll(RegExp(' +'), ' ').split(" ").map((str) => str.inCaps).join(" "); } \ No newline at end of file diff --git a/core/lib/presentation/extensions/html_extension.dart b/core/lib/presentation/extensions/html_extension.dart index fe3d1fb94..abbc18505 100644 --- a/core/lib/presentation/extensions/html_extension.dart +++ b/core/lib/presentation/extensions/html_extension.dart @@ -22,7 +22,7 @@ extension HtmlExtension on String { String addBlockQuoteTag() => addBlockTag( 'blockquote', - attribute: 'style=\"margin-left:8px;margin-right:8px;padding-left:12px;padding-right:12px;border-left:5px solid #eee;\"'); + attribute: 'style="margin-left:8px;margin-right:8px;padding-left:12px;padding-right:12px;border-left:5px solid #eee;"'); String asSignatureHtml() => '--

$this'; diff --git a/core/lib/presentation/extensions/list_extensions.dart b/core/lib/presentation/extensions/list_extensions.dart index 7c3b568c6..2656871ef 100644 --- a/core/lib/presentation/extensions/list_extensions.dart +++ b/core/lib/presentation/extensions/list_extensions.dart @@ -2,7 +2,7 @@ import 'package:built_collection/built_collection.dart'; import 'package:dartz/dartz.dart'; extension ListExtensions on List { - Tuple2, List> split(bool test(T element)) { + Tuple2, List> split(bool Function(T element) test) { final validBuilder = ListBuilder(); final invalidBuilder = ListBuilder(); forEach((element) { diff --git a/core/lib/presentation/extensions/url_extension.dart b/core/lib/presentation/extensions/url_extension.dart index 05b094b8c..8f6a9059f 100644 --- a/core/lib/presentation/extensions/url_extension.dart +++ b/core/lib/presentation/extensions/url_extension.dart @@ -1,8 +1,8 @@ import 'package:flutter/foundation.dart'; extension URLExtension on String { - static final String prefixUrlHttps = 'https://'; - static final String prefixUrlHttp = 'http://'; + static const String prefixUrlHttps = 'https://'; + static const String prefixUrlHttp = 'http://'; String formatURLValid() { if (isNotEmpty) { diff --git a/core/lib/presentation/utils/app_toast.dart b/core/lib/presentation/utils/app_toast.dart index cbf0e2755..3b95bdeeb 100644 --- a/core/lib/presentation/utils/app_toast.dart +++ b/core/lib/presentation/utils/app_toast.dart @@ -53,7 +53,7 @@ class AppToast { Color? textActionColor, } ) { - var trailingAction; + Widget? trailingAction; if (actionName != null) { if (actionIcon == null) { @@ -80,7 +80,7 @@ class AppToast { }, customBorder: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)), child: Padding( - padding: EdgeInsets.symmetric(vertical: 6, horizontal: 8), + padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 8), child: Row( mainAxisSize: MainAxisSize.min, children: [ @@ -156,7 +156,7 @@ class AppToast { shadowColor: Colors.black54, borderRadius: BorderRadius.all(Radius.circular(radius ?? 10)), child: Container( - padding: padding ?? EdgeInsets.symmetric(horizontal: 12.0, vertical: 14), + padding: padding ?? const EdgeInsets.symmetric(horizontal: 12.0, vertical: 14), decoration: BoxDecoration( borderRadius: BorderRadius.circular(radius ?? 10.0), color: bgColor ?? Colors.white, @@ -172,7 +172,7 @@ class AppToast { fit: BoxFit.fill, color: iconColor), if (icon != null) - SizedBox(width: 10.0), + const SizedBox(width: 10.0), Expanded(child: Text( message ?? '', style: textStyle ?? TextStyle(fontSize: 15, color: textColor ?? Colors.black))), @@ -184,7 +184,7 @@ class AppToast { fToast.showToast( child: toast, gravity: ToastGravity.BOTTOM, - toastDuration: toastLength ?? Duration(seconds: 3), + toastDuration: toastLength ?? const Duration(seconds: 3), ); } } diff --git a/core/lib/presentation/utils/html_transformer/html_template.dart b/core/lib/presentation/utils/html_transformer/html_template.dart index 017b3f850..d99e9b44c 100644 --- a/core/lib/presentation/utils/html_transformer/html_template.dart +++ b/core/lib/presentation/utils/html_transformer/html_template.dart @@ -1,7 +1,7 @@ -final nameClassToolTip = 'tmail-tooltip'; +const nameClassToolTip = 'tmail-tooltip'; -final tooltipLinkCss = ''' +const tooltipLinkCss = ''' .$nameClassToolTip .tooltiptext { visibility: hidden; max-width: 400px; @@ -54,13 +54,13 @@ String generateHtml(String content, { ${javaScripts ?? ''} -
${content}
+
$content
'''; } -final bodyCssStyleForEditor = ''' +const bodyCssStyleForEditor = '''