From 13299df1f7121223a574694b5bb3207a863b41cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Irland?= Date: Thu, 3 Nov 2022 13:01:22 -0300 Subject: [PATCH] Code metrics integration & Fix sort strings package issue (#19) --- .fvm/fvm_config.json | 2 +- analysis_options.yaml | 30 +++ android/fastlane/README.md | 8 + fastlane/Fastfile | 25 ++ fastlane/README.md | 16 ++ ios/fastlane/README.md | 8 + lib/core/common/config.dart | 4 +- lib/core/common/crash_report_tool.dart | 3 + lib/core/common/helper/env_helper.dart | 31 ++- lib/core/common/helper/future_helpers.dart | 1 - lib/core/common/logger.dart | 14 +- lib/core/common/network_exceptions.dart | 82 ++++--- lib/core/common/result.dart | 64 +++-- lib/core/di/di_repository_module.dart | 3 +- lib/core/model/common/file_type.dart | 3 +- lib/core/repository/project_repository.dart | 16 +- lib/core/repository/session_repository.dart | 6 +- lib/core/source/common/http_service.dart | 45 ++-- lib/core/source/project_remote_source.dart | 12 +- lib/core/source/tip_remote_source.dart | 6 +- lib/l10n/intl_en.arb | 8 +- lib/main.dart | 29 ++- lib/ui/app_router.dart | 7 +- lib/ui/app_router.gr.dart | 22 ++ lib/ui/common/input_text.dart | 9 +- lib/ui/main/main_state.dart | 5 +- .../error_handler_cubit.freezed.dart | 57 +---- .../error_handler/error_handler_state.dart | 12 +- .../section/error_handler/general_error.dart | 1 - .../error_handler/general_error.freezed.dart | 14 +- lib/ui/section/section_router.dart | 76 +++--- lib/ui/theme/app_colors.dart | 27 ++- lib/ui/theme/text_styles.dart | 81 ++----- pubspec.lock | 225 ++++++++++++++++-- pubspec.yaml | 15 +- scripts/checks.sh | 12 +- scripts/regenerate_fastlane_docs.sh | 5 + 37 files changed, 633 insertions(+), 351 deletions(-) delete mode 100644 lib/core/common/helper/future_helpers.dart create mode 100755 scripts/regenerate_fastlane_docs.sh diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json index 5d1bc03..85ad172 100644 --- a/.fvm/fvm_config.json +++ b/.fvm/fvm_config.json @@ -1,4 +1,4 @@ { - "flutterSdkVersion": "3.0.5", + "flutterSdkVersion": "3.3.6", "flavors": {} } \ No newline at end of file diff --git a/analysis_options.yaml b/analysis_options.yaml index 8f3e22c..6136cd4 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -28,11 +28,41 @@ linter: - curly_braces_in_flow_control_structures - slash_for_doc_comments +dart_code_metrics: + anti-patterns: + - long-method + - long-parameter-list + metrics: + cyclomatic-complexity: 20 + maximum-nesting-level: 5 + number-of-parameters: 4 + source-lines-of-code: 50 + metrics-exclude: + - test/** + rules: + - avoid-nested-conditional-expressions + - avoid-passing-async-when-sync-expected + - avoid-redundant-async + - no-boolean-literal-compare + - no-empty-block + - no-equal-then-else + - no-object-declaration + - prefer-conditional-expressions + - prefer-first + - prefer-immediate-return + - prefer-last + - prefer-moving-to-variable: + allowed-duplicated-chains: 3 + - prefer-trailing-comma + + + # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options analyzer: exclude: - '**/*.g.dart' - '**/*.gen.dart' + - '**/*.freezed.dart' errors: invalid_annotation_target: ignore diff --git a/android/fastlane/README.md b/android/fastlane/README.md index 380dc2c..53ee9f6 100644 --- a/android/fastlane/README.md +++ b/android/fastlane/README.md @@ -45,6 +45,14 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do **Lint: Analyze code** +### lint_code_metrics + +```sh +[bundle exec] fastlane lint_code_metrics +``` + +**Lint: Code metrics** + ### lints ```sh diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 1a490ac..5079437 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -44,15 +44,40 @@ lane :lint_format do flutter_command(command: "format --set-exit-if-changed .") end +desc "**Lint: Check code format**" +lane :lint_check_language_sorting do + current_content = sh_on_root(command: "cat lib/l10n/intl_en.arb") + flutter_command(command: "pub run arb_utils sort lib/l10n/intl_en.arb") + new_content = sh_on_root(command: "cat lib/l10n/intl_en.arb") + unless current_content == new_content + UI.user_error!("Language file is not sorted") + end +end + desc "**Lint: Analyze code**" lane :lint_analyze do flutter_command(command: "analyze .") end +desc "**Lint: Code metrics**" +lane :lint_code_metrics do + result = flutter_command(command: "pub run dart_code_metrics:metrics analyze lib --fatal-style --fatal-performance --fatal-warnings") + UI.message(result) + unless result.include? "✔ no issues found!" + UI.user_error!("Code metrics error happened") + end + + flutter_command(command: "pub run dart_code_metrics:metrics check-unused-code lib --fatal-unused") + flutter_command(command: "pub run dart_code_metrics:metrics check-unused-files lib --fatal-unused") +end + + desc "**Run linters**" lane :lints do lint_format + lint_check_language_sorting lint_analyze + lint_code_metrics end desc "**Check generated code is fine**" diff --git a/fastlane/README.md b/fastlane/README.md index 4fe20a8..8a3d91b 100644 --- a/fastlane/README.md +++ b/fastlane/README.md @@ -37,6 +37,14 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do **Lint: Check code format** +### lint_check_language_sorting + +```sh +[bundle exec] fastlane lint_check_language_sorting +``` + +**Lint: Check code format** + ### lint_analyze ```sh @@ -45,6 +53,14 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do **Lint: Analyze code** +### lint_code_metrics + +```sh +[bundle exec] fastlane lint_code_metrics +``` + +**Lint: Code metrics** + ### lints ```sh diff --git a/ios/fastlane/README.md b/ios/fastlane/README.md index 8efa164..9ff5dfc 100644 --- a/ios/fastlane/README.md +++ b/ios/fastlane/README.md @@ -45,6 +45,14 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do **Lint: Analyze code** +### lint_code_metrics + +```sh +[bundle exec] fastlane lint_code_metrics +``` + +**Lint: Code metrics** + ### lints ```sh diff --git a/lib/core/common/config.dart b/lib/core/common/config.dart index e57a268..c10fe12 100644 --- a/lib/core/common/config.dart +++ b/lib/core/common/config.dart @@ -35,7 +35,9 @@ abstract class Config { static String gitHubTipsNameFolder = 'tipsandtricks/'; static final _environment = enumFromString( - Environments.values, const String.fromEnvironment('ENV')) ?? + Environments.values, + const String.fromEnvironment('ENV'), + ) ?? Environments.development; static Future initialize() async { diff --git a/lib/core/common/crash_report_tool.dart b/lib/core/common/crash_report_tool.dart index 075016c..c80f887 100644 --- a/lib/core/common/crash_report_tool.dart +++ b/lib/core/common/crash_report_tool.dart @@ -11,11 +11,14 @@ abstract class CrashReportTool { class NoOpsCrashReportTool extends CrashReportTool { @override + // ignore: no-empty-block, avoid-redundant-async Future init() async {} @override + // ignore: no-empty-block, avoid-redundant-async Future logFatal(error, StackTrace? stackTrace) async {} @override + // ignore: no-empty-block, avoid-redundant-async Future logNonFatal(LogEvent event) async {} } diff --git a/lib/core/common/helper/env_helper.dart b/lib/core/common/helper/env_helper.dart index 5620a20..91599e9 100644 --- a/lib/core/common/helper/env_helper.dart +++ b/lib/core/common/helper/env_helper.dart @@ -3,21 +3,26 @@ import 'dart:async'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_template/core/common/logger.dart'; -Future> loadEnvs(String path, - [bool ignoreErrors = true]) async { +Future> loadEnvs( + String path, [ + bool ignoreErrors = true, +]) async { final dotEnv = DotEnv(); final completer = Completer>(); // ignore: unawaited_futures - runZonedGuarded(() async { - await dotEnv.load(fileName: path); - completer.complete(dotEnv.env); - }, (e, s) { - Logger.d('$path file is not valid.', e); - if (ignoreErrors) { - completer.complete({}); - } else { - completer.completeError(e, s); - } - }); + runZonedGuarded( + () async { + await dotEnv.load(fileName: path); + completer.complete(dotEnv.env); + }, + (e, s) { + Logger.d('$path file is not valid.', e); + if (ignoreErrors) { + completer.complete({}); + } else { + completer.completeError(e, s); + } + }, + ); return completer.future; } diff --git a/lib/core/common/helper/future_helpers.dart b/lib/core/common/helper/future_helpers.dart deleted file mode 100644 index 43ba4e2..0000000 --- a/lib/core/common/helper/future_helpers.dart +++ /dev/null @@ -1 +0,0 @@ -Future wrapInFuture(Function() callback) => Future(() => callback()); diff --git a/lib/core/common/logger.dart b/lib/core/common/logger.dart index 3cc72ec..ef08b3b 100644 --- a/lib/core/common/logger.dart +++ b/lib/core/common/logger.dart @@ -60,7 +60,13 @@ class _CrashReportWrappedPrinter extends LogPrinter { var trace = Trace.current(4); var frames = trace.frames; final newFrames = frames.map( - (frame) => Frame(frame.uri, frame.line, frame.column, frame.member)); + (frame) => Frame( + frame.uri, + frame.line, + frame.column, + frame.member, + ), + ); return _PrintableTrace(newFrames); } @@ -103,8 +109,10 @@ class _PrintableTrace extends Trace { return frames.map((frame) { var number = '#${i++}'.padRight(8); var member = frame.member! - .replaceAllMapped(RegExp(r'[^.]+\.'), - (match) => '${match[1]}.<${match[1]}_async_body>') + .replaceAllMapped( + RegExp(r'[^.]+\.'), + (match) => '${match[1]}.<${match[1]}_async_body>', + ) .replaceAll('', ''); var line = frame.line ?? 0; var column = frame.column ?? 0; diff --git a/lib/core/common/network_exceptions.dart b/lib/core/common/network_exceptions.dart index 1393dc1..2da0f79 100644 --- a/lib/core/common/network_exceptions.dart +++ b/lib/core/common/network_exceptions.dart @@ -94,45 +94,59 @@ class NetworkException extends Object with _$NetworkException { return const NetworkException.unexpectedError(); } } else { - if (error.toString().contains('is not a subtype of')) { - return const NetworkException.unableToProcess(); - } else { - return const NetworkException.unexpectedError(); - } + return error.toString().contains('is not a subtype of') + ? const NetworkException.unableToProcess() + : const NetworkException.unexpectedError(); } } static String getErrorMessage(NetworkException networkExceptions) { var errorMessage = ''; - networkExceptions.when(notImplemented: () { - errorMessage = 'Not Implemented'; - }, internalServerError: () { - errorMessage = 'Internal Server Error'; - }, notFound: (String reason) { - errorMessage = reason; - }, serviceUnavailable: () { - errorMessage = 'Service unavailable'; - }, methodNotAllowed: () { - errorMessage = 'Method Allowed'; - }, badRequest: () { - errorMessage = 'Bad request'; - }, unauthorizedRequest: (body) { - errorMessage = 'Unauthorized request - $body'; - }, unexpectedError: () { - errorMessage = 'Unexpected error occurred'; - }, noInternetConnection: () { - errorMessage = 'No internet connection'; - }, conflict: () { - errorMessage = 'Error due to a conflict'; - }, unableToProcess: () { - errorMessage = 'Unable to process the data'; - }, defaultError: (int? code, String? error) { - errorMessage = error ?? 'Unexpected error occurred'; - }, formatException: () { - errorMessage = 'Unexpected error occurred'; - }, notAcceptable: () { - errorMessage = 'Not acceptable'; - }); + networkExceptions.when( + notImplemented: () { + errorMessage = 'Not Implemented'; + }, + internalServerError: () { + errorMessage = 'Internal Server Error'; + }, + notFound: (String reason) { + errorMessage = reason; + }, + serviceUnavailable: () { + errorMessage = 'Service unavailable'; + }, + methodNotAllowed: () { + errorMessage = 'Method Allowed'; + }, + badRequest: () { + errorMessage = 'Bad request'; + }, + unauthorizedRequest: (body) { + errorMessage = 'Unauthorized request - $body'; + }, + unexpectedError: () { + errorMessage = 'Unexpected error occurred'; + }, + noInternetConnection: () { + errorMessage = 'No internet connection'; + }, + conflict: () { + errorMessage = 'Error due to a conflict'; + }, + unableToProcess: () { + errorMessage = 'Unable to process the data'; + }, + defaultError: (int? code, String? error) { + errorMessage = error ?? 'Unexpected error occurred'; + }, + formatException: () { + errorMessage = 'Unexpected error occurred'; + }, + notAcceptable: () { + errorMessage = 'Not acceptable'; + }, + ); + return errorMessage; } } diff --git a/lib/core/common/result.dart b/lib/core/common/result.dart index 690766d..8e9a8f4 100644 --- a/lib/core/common/result.dart +++ b/lib/core/common/result.dart @@ -1,3 +1,5 @@ +// ignore_for_file: no-object-declaration + import 'package:equatable/equatable.dart'; // Code: https://gist.githubusercontent.com/CassiusPacheco/409e66e220ce563440df00385f39ac98/raw/d0506e4b3dadbcf5a21d9cc23b300ecbcc8c57d6/data_result.dart @@ -53,7 +55,9 @@ abstract class Result extends Equatable { /// the matching function to the object type will be executed. For example, /// for a `SuccessResult` object only the [fnData] function will be executed. Result either( - Object Function(Object error) fnFailure, T Function(S data) fnData); + Object Function(Object error) fnFailure, + T Function(S data) fnData, + ); /// Transforms value of [data] allowing a new `DataResult` to be returned. /// A `SuccessResult` might return a `FailureResult` and vice versa. @@ -67,7 +71,10 @@ abstract class Result extends Equatable { /// Folds [error] and [data] into the value of one type. Only the matching /// function to the object type will be executed. For example, for a /// `SuccessResult` object only the [fnData] function will be executed. - T fold(T Function(Object error) fnFailure, T Function(S data) fnData); + T fold( + T Function(Object error) fnFailure, + T Function(S data) fnData, + ); @override List get props => [if (isSuccess) data else error]; @@ -82,24 +89,24 @@ class _SuccessResult extends Result { @override _SuccessResult either( - Object Function(Object error) fnFailure, T Function(S data) fnData) { - return _SuccessResult(fnData(_value)); - } + Object Function(Object error) fnFailure, + T Function(S data) fnData, + ) => + _SuccessResult(fnData(_value)); @override - Result then(Result Function(S data) fnData) { - return fnData(_value); - } + Result then(Result Function(S data) fnData) => fnData(_value); @override - _SuccessResult map(T Function(S data) fnData) { - return _SuccessResult(fnData(_value)); - } + _SuccessResult map(T Function(S data) fnData) => + _SuccessResult(fnData(_value)); @override - T fold(T Function(Object error) fnFailure, T Function(S data) fnData) { - return fnData(_value); - } + T fold( + T Function(Object error) fnFailure, + T Function(S data) fnData, + ) => + fnData(_value); } /// Failure implementation of `DataResult`. It contains `error`. It's @@ -111,22 +118,27 @@ class _FailureResult extends Result { @override _FailureResult either( - Object Function(Object error) fnFailure, T Function(S data) fnData) { - return _FailureResult(fnFailure(_value)); - } + Object Function(Object error) fnFailure, + T Function(S data) fnData, + ) => + _FailureResult(fnFailure(_value)); @override - _FailureResult map(T Function(S data) fnData) { - return _FailureResult(_value); - } + _FailureResult map( + T Function(S data) fnData, + ) => + _FailureResult(_value); @override - _FailureResult then(Result Function(S data) fnData) { - return _FailureResult(_value); - } + _FailureResult then( + Result Function(S data) fnData, + ) => + _FailureResult(_value); @override - T fold(T Function(Object error) fnFailure, T Function(S data) fnData) { - return fnFailure(_value); - } + T fold( + T Function(Object error) fnFailure, + T Function(S data) fnData, + ) => + fnFailure(_value); } diff --git a/lib/core/di/di_repository_module.dart b/lib/core/di/di_repository_module.dart index d2bc21f..cf1b619 100644 --- a/lib/core/di/di_repository_module.dart +++ b/lib/core/di/di_repository_module.dart @@ -31,7 +31,8 @@ extension _GetItUseCaseDiModuleExtensions on GetIt { registerLazySingleton(FlutterSecureStorage.new); registerLazySingleton(() => HttpServiceDio([AuthInterceptor(get())])); registerSingletonAsync( - () => $FloorAppDatabase.databaseBuilder('app_database.db').build()); + () => $FloorAppDatabase.databaseBuilder('app_database.db').build(), + ); } void _setupRepositories() { diff --git a/lib/core/model/common/file_type.dart b/lib/core/model/common/file_type.dart index 192f01a..e5889cd 100644 --- a/lib/core/model/common/file_type.dart +++ b/lib/core/model/common/file_type.dart @@ -11,5 +11,6 @@ enum FileType { final String _pathRegex; static FileType? fromPath(String path) => FileType.values.firstOrNullWhere( - (fileType) => RegExp(fileType._pathRegex).hasMatch(path)); + (fileType) => RegExp(fileType._pathRegex).hasMatch(path), + ); } diff --git a/lib/core/repository/project_repository.dart b/lib/core/repository/project_repository.dart index b256c5c..0fc38a7 100644 --- a/lib/core/repository/project_repository.dart +++ b/lib/core/repository/project_repository.dart @@ -16,14 +16,14 @@ class ProjectRepository { ProjectRepository(this._projectLocalSource, this._projectRemoteSource) : _store = Stock( - fetcher: - Fetcher.ofFuture((_) => _projectRemoteSource.getProjects()), - sourceOfTruth: SourceOfTruth>( - reader: (_) => _projectLocalSource.getProjects(), - writer: (_, value) async { - await _projectLocalSource.replaceProjects(value); - }, - ).mapToUsingMapper(ProjectListStockTypeMapper())); + fetcher: Fetcher.ofFuture( + (_) => _projectRemoteSource.getProjects(), + ), + sourceOfTruth: SourceOfTruth>( + reader: (_) => _projectLocalSource.getProjects(), + writer: (_, value) => _projectLocalSource.replaceProjects(value), + ).mapToUsingMapper(ProjectListStockTypeMapper()), + ); Stream?> getProjects() => _store .stream(null) diff --git a/lib/core/repository/session_repository.dart b/lib/core/repository/session_repository.dart index e645758..ec6e4b6 100644 --- a/lib/core/repository/session_repository.dart +++ b/lib/core/repository/session_repository.dart @@ -24,8 +24,10 @@ class SessionRepository { Stream getUserInfo() => _authLocalSource.getUser(); - Future signInUser( - {required String email, required String password}) async { + Future signInUser({ + required String email, + required String password, + }) async { final response = await _authRemoteSource.signIn(email, password); await _authLocalSource.saveUserToken(response.accessToken); await _authLocalSource.saveUserInfo(response.user); diff --git a/lib/core/source/common/http_service.dart b/lib/core/source/common/http_service.dart index 6b1e7fe..51bac44 100644 --- a/lib/core/source/common/http_service.dart +++ b/lib/core/source/common/http_service.dart @@ -1,3 +1,4 @@ +// ignore_for_file: long-parameter-list import 'dart:core'; import 'package:dio/dio.dart'; @@ -63,7 +64,7 @@ class HttpServiceDio implements HttpService { Options? options, CancelToken? cancelToken, ProgressCallback? onReceiveProgress, - }) async => + }) => _processNetworkCall(() => _dio.get( uri, queryParameters: queryParameters, @@ -80,7 +81,7 @@ class HttpServiceDio implements HttpService { CancelToken? cancelToken, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, - }) async => + }) => _processNetworkCall(() => _dio.delete( uri, data: data, @@ -90,13 +91,15 @@ class HttpServiceDio implements HttpService { )); @override - Future post(String uri, - {data, - Map? queryParameters, - Options? options, - CancelToken? cancelToken, - ProgressCallback? onSendProgress, - ProgressCallback? onReceiveProgress}) async => + Future post( + String uri, { + data, + Map? queryParameters, + Options? options, + CancelToken? cancelToken, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) => _processNetworkCall(() => _dio.post( uri, data: data, @@ -106,13 +109,15 @@ class HttpServiceDio implements HttpService { )); @override - Future put(String uri, - {data, - Map? queryParameters, - Options? options, - CancelToken? cancelToken, - ProgressCallback? onSendProgress, - ProgressCallback? onReceiveProgress}) => + Future put( + String uri, { + data, + Map? queryParameters, + Options? options, + CancelToken? cancelToken, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) => _processNetworkCall(() => _dio.put( uri, data: data, @@ -122,8 +127,9 @@ class HttpServiceDio implements HttpService { )); Future _processNetworkCall( - Future Function() call) async => - await call().catchError((e) => throw NetworkException.getDioException(e)); + Future Function() call, + ) => + call().catchError((e) => throw NetworkException.getDioException(e)); } extension HttpServiceCommon on HttpService { @@ -216,7 +222,8 @@ extension ResponseExtensions on Response { bool get isSuccess => statusCode == 200; ServiceResponse processServiceResponse( - R Function(dynamic json) serializer) { + R Function(dynamic json) serializer, + ) { if (isSuccess) { return ServiceResponse.data(serializer(data)); } diff --git a/lib/core/source/project_remote_source.dart b/lib/core/source/project_remote_source.dart index e48ca5c..0fd29eb 100644 --- a/lib/core/source/project_remote_source.dart +++ b/lib/core/source/project_remote_source.dart @@ -9,10 +9,12 @@ class ProjectRemoteSource { ProjectRemoteSource(this._httpService); - Future> getProjects() async => _httpService - .getAndProcessResponse(_urlGetProjects, - serializer: (listResponse) => (listResponse as List) - .map((project) => Project.fromJson(project)) - .toList()) + Future> getProjects() => _httpService + .getAndProcessResponse( + _urlGetProjects, + serializer: (listResponse) => (listResponse as List) + .map((project) => Project.fromJson(project)) + .toList(), + ) .then((value) => value.getDataOrThrow()); } diff --git a/lib/core/source/tip_remote_source.dart b/lib/core/source/tip_remote_source.dart index 29bbe34..59e07da 100644 --- a/lib/core/source/tip_remote_source.dart +++ b/lib/core/source/tip_remote_source.dart @@ -14,8 +14,10 @@ class TipRemoteSource { TipRemoteSource(this._httpService); Future> getTips() => _httpService - .getAndProcessResponse(_urlGetGithubFiles, - serializer: (file) => GitHubTreeResponse.fromJson(file)) + .getAndProcessResponse( + _urlGetGithubFiles, + serializer: (file) => GitHubTreeResponse.fromJson(file), + ) .then((value) => value.getDataOrThrow()) .then(_processTips); diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index e547322..83da22a 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -15,10 +15,10 @@ "error_no_internet_connection_error_title": "Error", "error_unknown_error_description": "Something went wrong!", "error_unknown_error_title": "Ops!", + "home": "Home", "log_out": "Log out", "mail": "Mail", "password": "Password", - "home": "Home", - "xmartlabs_projects": "Xmartlabs' projects", - "search": "Search" -} + "search": "Search", + "xmartlabs_projects": "Xmartlabs' projects" +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 892093f..78c58fc 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -10,19 +10,21 @@ import 'package:flutter_template/core/di/di_provider.dart'; import 'package:flutter_template/ui/main/main_screen.dart'; Future main() async { - await runZonedGuarded(() async { - final widgetsBinding = WidgetsFlutterBinding.ensureInitialized(); - FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding); - await SystemChrome.setPreferredOrientations([ - DeviceOrientation.landscapeLeft, - DeviceOrientation.landscapeRight, - ]); - await _initSdks(); - runApp(const MyApp()); - FlutterNativeSplash.remove(); - }, (exception, stackTrace) async { - await Logger.fatal(error: exception, stackTrace: stackTrace); - }); + await runZonedGuarded( + () async { + final widgetsBinding = WidgetsFlutterBinding.ensureInitialized(); + FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding); + await SystemChrome.setPreferredOrientations([ + DeviceOrientation.landscapeLeft, + DeviceOrientation.landscapeRight, + ]); + await _initSdks(); + runApp(const MyApp()); + FlutterNativeSplash.remove(); + }, + (exception, stackTrace) => + Logger.fatal(error: exception, stackTrace: stackTrace), + ); } Future _initSdks() async { @@ -36,6 +38,7 @@ Future _initSdks() async { ]); } +// ignore: avoid-redundant-async Future _initFirebaseSdks() async { // TODO: Add Craslytics, Analytics and other sdks that the project needs } diff --git a/lib/ui/app_router.dart b/lib/ui/app_router.dart index 9c6d7c2..007b103 100644 --- a/lib/ui/app_router.dart +++ b/lib/ui/app_router.dart @@ -1,4 +1,5 @@ import 'package:auto_route/auto_route.dart'; +import 'package:flutter_template/ui/catalog/catalog_screen.dart'; import 'package:flutter_template/ui/section/section_router.dart'; import 'package:flutter_template/ui/home/home_screen.dart'; import 'package:flutter/material.dart'; @@ -8,6 +9,10 @@ part 'app_router.gr.dart'; @MaterialAutoRouter( replaceInRouteName: 'Page,Route,Screen', routes: [ + AutoRoute( + name: 'CatalogRouter', + page: CatalogScreen, + ), AutoRoute( name: 'UnauthenticatedRouter', page: SectionRouter, @@ -23,7 +28,7 @@ part 'app_router.gr.dart'; initial: true, ), ], - ) + ), ], ) class AppRouter extends _$AppRouter { diff --git a/lib/ui/app_router.gr.dart b/lib/ui/app_router.gr.dart index 27c61e5..708aa61 100644 --- a/lib/ui/app_router.gr.dart +++ b/lib/ui/app_router.gr.dart @@ -17,6 +17,12 @@ class _$AppRouter extends RootStackRouter { @override final Map pagesMap = { + CatalogRouter.name: (routeData) { + return MaterialPageX( + routeData: routeData, + child: CatalogScreen(), + ); + }, UnauthenticatedRouter.name: (routeData) { return MaterialPageX( routeData: routeData, @@ -39,6 +45,10 @@ class _$AppRouter extends RootStackRouter { @override List get routes => [ + RouteConfig( + CatalogRouter.name, + path: '/catalog-screen', + ), RouteConfig( UnauthenticatedRouter.name, path: '/section-router', @@ -64,6 +74,18 @@ class _$AppRouter extends RootStackRouter { ]; } +/// generated route for +/// [CatalogScreen] +class CatalogRouter extends PageRouteInfo { + const CatalogRouter() + : super( + CatalogRouter.name, + path: '/catalog-screen', + ); + + static const String name = 'CatalogRouter'; +} + /// generated route for /// [SectionRouter] class UnauthenticatedRouter extends PageRouteInfo { diff --git a/lib/ui/common/input_text.dart b/lib/ui/common/input_text.dart index 31a01e5..d150096 100644 --- a/lib/ui/common/input_text.dart +++ b/lib/ui/common/input_text.dart @@ -34,10 +34,11 @@ class InputText extends StatelessWidget { filled: true, fillColor: backgroundColor ?? context.theme.colors.surface, border: OutlineInputBorder( - borderSide: error != null - ? BorderSide(color: context.theme.colors.primary.shade300) - : BorderSide(color: context.theme.colors.error), - borderRadius: BorderRadius.circular(4.r)), + borderSide: error != null + ? BorderSide(color: context.theme.colors.primary.shade300) + : BorderSide(color: context.theme.colors.error), + borderRadius: BorderRadius.circular(4.r), + ), prefixIcon: Icon(leadingIcon), hintText: textHint, suffixIcon: error != null diff --git a/lib/ui/main/main_state.dart b/lib/ui/main/main_state.dart index b25371b..f4a124e 100644 --- a/lib/ui/main/main_state.dart +++ b/lib/ui/main/main_state.dart @@ -2,6 +2,7 @@ part of 'main_cubit.dart'; @freezed class MainBaseState with _$MainBaseState { - const factory MainBaseState.state( - {@Default(null) AuthenticationStatus? authenticationStatus}) = _MainState; + const factory MainBaseState.state({ + @Default(null) AuthenticationStatus? authenticationStatus, + }) = _MainState; } diff --git a/lib/ui/section/error_handler/error_handler_cubit.freezed.dart b/lib/ui/section/error_handler/error_handler_cubit.freezed.dart index 124871a..d0fd819 100644 --- a/lib/ui/section/error_handler/error_handler_cubit.freezed.dart +++ b/lib/ui/section/error_handler/error_handler_cubit.freezed.dart @@ -111,22 +111,14 @@ class __$$_InitErrorHandlerStateCopyWithImpl<$Res> /// @nodoc -class _$_InitErrorHandlerState - with DiagnosticableTreeMixin - implements _InitErrorHandlerState { +class _$_InitErrorHandlerState implements _InitErrorHandlerState { const _$_InitErrorHandlerState(); @override - String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { + String toString() { return 'ErrorHandlerState.init()'; } - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties.add(DiagnosticsProperty('type', 'ErrorHandlerState.init')); - } - @override bool operator ==(dynamic other) { return identical(this, other) || @@ -257,9 +249,7 @@ class __$$_UnknownErrorHandlerStateCopyWithImpl<$Res> /// @nodoc -class _$_UnknownErrorHandlerState - with DiagnosticableTreeMixin - implements _UnknownErrorHandlerState { +class _$_UnknownErrorHandlerState implements _UnknownErrorHandlerState { const _$_UnknownErrorHandlerState(this.error, [this.retry]); @override @@ -268,19 +258,10 @@ class _$_UnknownErrorHandlerState final VoidCallback? retry; @override - String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { + String toString() { return 'ErrorHandlerState.unknownError(error: $error, retry: $retry)'; } - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('type', 'ErrorHandlerState.unknownError')) - ..add(DiagnosticsProperty('error', error)) - ..add(DiagnosticsProperty('retry', retry)); - } - @override bool operator ==(dynamic other) { return identical(this, other) || @@ -427,27 +408,17 @@ class __$$_InternetErrorHandlerStateCopyWithImpl<$Res> /// @nodoc -class _$_InternetErrorHandlerState - with DiagnosticableTreeMixin - implements _InternetErrorHandlerState { +class _$_InternetErrorHandlerState implements _InternetErrorHandlerState { const _$_InternetErrorHandlerState([this.retry]); @override final VoidCallback? retry; @override - String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { + String toString() { return 'ErrorHandlerState.internetError(retry: $retry)'; } - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('type', 'ErrorHandlerState.internetError')) - ..add(DiagnosticsProperty('retry', retry)); - } - @override bool operator ==(dynamic other) { return identical(this, other) || @@ -600,9 +571,7 @@ class __$$_GeneralErrorHandlerStateCopyWithImpl<$Res> /// @nodoc -class _$_GeneralErrorHandlerState - with DiagnosticableTreeMixin - implements _GeneralErrorHandlerState { +class _$_GeneralErrorHandlerState implements _GeneralErrorHandlerState { const _$_GeneralErrorHandlerState(this.title, this.description, [this.retry]); @override @@ -613,20 +582,10 @@ class _$_GeneralErrorHandlerState final VoidCallback? retry; @override - String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { + String toString() { return 'ErrorHandlerState.generalError(title: $title, description: $description, retry: $retry)'; } - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('type', 'ErrorHandlerState.generalError')) - ..add(DiagnosticsProperty('title', title)) - ..add(DiagnosticsProperty('description', description)) - ..add(DiagnosticsProperty('retry', retry)); - } - @override bool operator ==(dynamic other) { return identical(this, other) || diff --git a/lib/ui/section/error_handler/error_handler_state.dart b/lib/ui/section/error_handler/error_handler_state.dart index 7d0a36b..333decc 100644 --- a/lib/ui/section/error_handler/error_handler_state.dart +++ b/lib/ui/section/error_handler/error_handler_state.dart @@ -4,13 +4,17 @@ part of 'error_handler_cubit.dart'; class ErrorHandlerState with _$ErrorHandlerState { const factory ErrorHandlerState.init() = _InitErrorHandlerState; - const factory ErrorHandlerState.unknownError(Object? error, - [VoidCallback? retry]) = _UnknownErrorHandlerState; + const factory ErrorHandlerState.unknownError( + Object? error, [ + VoidCallback? retry, + ]) = _UnknownErrorHandlerState; const factory ErrorHandlerState.internetError([VoidCallback? retry]) = _InternetErrorHandlerState; const factory ErrorHandlerState.generalError( - String? title, String description, [VoidCallback? retry]) = - _GeneralErrorHandlerState; + String? title, + String description, [ + VoidCallback? retry, + ]) = _GeneralErrorHandlerState; } diff --git a/lib/ui/section/error_handler/general_error.dart b/lib/ui/section/error_handler/general_error.dart index 5d1f04f..0faf2f9 100644 --- a/lib/ui/section/error_handler/general_error.dart +++ b/lib/ui/section/error_handler/general_error.dart @@ -1,4 +1,3 @@ -import 'package:flutter/foundation.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; part 'general_error.freezed.dart'; diff --git a/lib/ui/section/error_handler/general_error.freezed.dart b/lib/ui/section/error_handler/general_error.freezed.dart index 8781be5..c850d0d 100644 --- a/lib/ui/section/error_handler/general_error.freezed.dart +++ b/lib/ui/section/error_handler/general_error.freezed.dart @@ -110,7 +110,7 @@ class __$$_GeneralErrorCopyWithImpl<$Res> /// @nodoc -class _$_GeneralError with DiagnosticableTreeMixin implements _GeneralError { +class _$_GeneralError implements _GeneralError { const _$_GeneralError({this.title, required this.description, this.cause}); @override @@ -121,20 +121,10 @@ class _$_GeneralError with DiagnosticableTreeMixin implements _GeneralError { final dynamic cause; @override - String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { + String toString() { return 'GeneralError(title: $title, description: $description, cause: $cause)'; } - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('type', 'GeneralError')) - ..add(DiagnosticsProperty('title', title)) - ..add(DiagnosticsProperty('description', description)) - ..add(DiagnosticsProperty('cause', cause)); - } - @override bool operator ==(dynamic other) { return identical(this, other) || diff --git a/lib/ui/section/section_router.dart b/lib/ui/section/section_router.dart index f2bd44d..158ee5e 100644 --- a/lib/ui/section/section_router.dart +++ b/lib/ui/section/section_router.dart @@ -18,42 +18,48 @@ class SectionRouter extends StatelessWidget { void showError(BuildContext context, ErrorHandlerState error) { error.when( - init: () => {}, - unknownError: (error, retry) => _showDialog( - context, - context.localizations.error_unknown_error_title, - context.localizations.error_unknown_error_description, - retry, - ), - internetError: (retry) => _showDialog( - context, - context.localizations.error_no_internet_connection_error_title, - context - .localizations.error_no_internet_connection_error_description, - retry, - ), - generalError: (title, description, retry) => - _showDialog(context, title, description, retry)); + init: () => {}, + unknownError: (error, retry) => _showDialog( + context, + context.localizations.error_unknown_error_title, + context.localizations.error_unknown_error_description, + retry, + ), + internetError: (retry) => _showDialog( + context, + context.localizations.error_no_internet_connection_error_title, + context.localizations.error_no_internet_connection_error_description, + retry, + ), + generalError: (title, description, retry) => + _showDialog(context, title, description, retry), + ); } - void _showDialog(BuildContext context, String? title, String description, - VoidCallback? retry) => + void _showDialog( + BuildContext context, + String? title, + String description, + VoidCallback? retry, + ) => showDialog( - context: context, - builder: (context) => AlertDialog( - title: Text( - title ?? context.localizations.error_unknown_error_title), - content: Text(description), - actions: [ - if (retry != null) - TextButton( - onPressed: () => Navigator.pop(context), - child: Text(context.localizations.error_button_retry), - ), - TextButton( - onPressed: () => Navigator.pop(context), - child: Text(context.localizations.error_button_ok), - ), - ], - )); + context: context, + builder: (context) => AlertDialog( + title: Text( + title ?? context.localizations.error_unknown_error_title, + ), + content: Text(description), + actions: [ + if (retry != null) + TextButton( + onPressed: () => Navigator.pop(context), + child: Text(context.localizations.error_button_retry), + ), + TextButton( + onPressed: () => Navigator.pop(context), + child: Text(context.localizations.error_button_ok), + ), + ], + ), + ); } diff --git a/lib/ui/theme/app_colors.dart b/lib/ui/theme/app_colors.dart index b610f7a..80969eb 100644 --- a/lib/ui/theme/app_colors.dart +++ b/lib/ui/theme/app_colors.dart @@ -72,19 +72,20 @@ class AppColors extends ColorScheme { required this.warning, required this.onWarning, }) : super( - brightness: brightness, - primary: primary, - onPrimary: onPrimary, - secondary: secondary, - onSecondary: onSecondary, - error: error, - onError: onError, - background: background, - onBackground: onBackground, - surface: surface, - onSurface: onSurface, - tertiary: tertiary, - onTertiary: onTertiary); + brightness: brightness, + primary: primary, + onPrimary: onPrimary, + secondary: secondary, + onSecondary: onSecondary, + error: error, + onError: onError, + background: background, + onBackground: onBackground, + surface: surface, + onSurface: onSurface, + tertiary: tertiary, + onTertiary: onTertiary, + ); static AppColors getColorScheme() => AppColors( brightness: Brightness.light, diff --git a/lib/ui/theme/text_styles.dart b/lib/ui/theme/text_styles.dart index 02ef628..d45d5d9 100644 --- a/lib/ui/theme/text_styles.dart +++ b/lib/ui/theme/text_styles.dart @@ -67,70 +67,27 @@ class AppStyles extends TextTheme { fontWeight: FontWeight.w300, fontStyle: FontStyle.normal, ), - textTheme: GoogleFonts.interTextTheme().copyWith( - displayLarge: GoogleFonts.roboto( - fontSize: 57.sp, - fontWeight: FontWeight.w400, - ), - displayMedium: GoogleFonts.roboto( - fontSize: 45.sp, - fontWeight: FontWeight.w400, - ), - displaySmall: GoogleFonts.roboto( - fontSize: 36.sp, - fontWeight: FontWeight.w400, - ), - headlineLarge: GoogleFonts.roboto( - fontSize: 32.sp, - fontWeight: FontWeight.w400, - ), - headlineMedium: GoogleFonts.roboto( - fontSize: 28, - fontWeight: FontWeight.w400, - ), - headlineSmall: GoogleFonts.roboto( - fontSize: 24, - fontWeight: FontWeight.w400, - ), - titleLarge: GoogleFonts.roboto( - fontSize: 22.sp, - fontWeight: FontWeight.w400, - ), - titleMedium: GoogleFonts.roboto( - fontSize: 16.sp, - fontWeight: FontWeight.w500, - ), - titleSmall: GoogleFonts.roboto( - fontSize: 14.sp, - fontWeight: FontWeight.w500, - ), - labelLarge: GoogleFonts.roboto( - fontSize: 14.sp, - fontWeight: FontWeight.w500, - ), - labelMedium: GoogleFonts.roboto( - fontSize: 12.sp, - fontWeight: FontWeight.w500, - ), - labelSmall: GoogleFonts.roboto( - fontSize: 11.sp, - fontWeight: FontWeight.w500, - ), - bodyLarge: GoogleFonts.roboto( - fontSize: 16.sp, - fontWeight: FontWeight.w400, - height: 1.sp, - ), - bodyMedium: GoogleFonts.roboto( - fontSize: 14.sp, - fontWeight: FontWeight.w400, - ), - bodySmall: GoogleFonts.roboto( - fontSize: 12.sp, - fontWeight: FontWeight.w400, - ), + textTheme: GoogleFonts.robotoTextTheme().copyWith( + displayLarge: _robotoTextStyle(57.sp, FontWeight.w400), + displayMedium: _robotoTextStyle(45.sp, FontWeight.w400), + displaySmall: _robotoTextStyle(36.sp, FontWeight.w400), + headlineLarge: _robotoTextStyle(32.sp, FontWeight.w400), + headlineMedium: _robotoTextStyle(28, FontWeight.w400), + headlineSmall: _robotoTextStyle(24, FontWeight.w400), + titleLarge: _robotoTextStyle(22.sp, FontWeight.w400), + titleMedium: _robotoTextStyle(16.sp, FontWeight.w500), + titleSmall: _robotoTextStyle(14.sp, FontWeight.w500), + labelLarge: _robotoTextStyle(14.sp, FontWeight.w500), + labelMedium: _robotoTextStyle(12.sp, FontWeight.w500), + labelSmall: _robotoTextStyle(11.sp, FontWeight.w500), + bodyLarge: _robotoTextStyle(16.sp, FontWeight.w400), + bodyMedium: _robotoTextStyle(14.sp, FontWeight.w400), + bodySmall: _robotoTextStyle(12.sp, FontWeight.w400), ), ); + static TextStyle _robotoTextStyle(double fontSize, FontWeight fontWeight) => + GoogleFonts.roboto(fontSize: fontSize, fontWeight: fontWeight); + TextTheme getThemeData() => getAppStyles(); } diff --git a/pubspec.lock b/pubspec.lock index 24c7d63..50b29a4 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -15,13 +15,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.7.0" + analyzer_plugin: + dependency: transitive + description: + name: analyzer_plugin + url: "https://pub.dartlang.org" + source: hosted + version: "0.10.0" + ansicolor: + dependency: transitive + description: + name: ansicolor + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" arb_utils: - dependency: "direct main" + dependency: "direct dev" description: name: arb_utils url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.4.0" archive: dependency: transitive description: @@ -42,7 +56,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" auto_route: dependency: "direct main" description: @@ -57,6 +71,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "5.0.2" + basic_utils: + dependency: transitive + description: + name: basic_utils + url: "https://pub.dartlang.org" + source: hosted + version: "3.9.4" bloc: dependency: "direct main" description: @@ -105,7 +126,7 @@ packages: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "2.3.0" + version: "2.3.2" build_runner_core: dependency: transitive description: @@ -133,21 +154,28 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" - charcode: + version: "1.2.1" + checked_yaml: dependency: transitive description: - name: charcode + name: checked_yaml url: "https://pub.dartlang.org" source: hosted - version: "1.3.1" - checked_yaml: + version: "2.0.1" + chunked_stream: dependency: transitive description: - name: checked_yaml + name: chunked_stream url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "1.4.1" + circular_buffer: + dependency: transitive + description: + name: circular_buffer + url: "https://pub.dartlang.org" + source: hosted + version: "0.11.0" cli_util: dependency: transitive description: @@ -161,7 +189,7 @@ packages: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" code_builder: dependency: transitive description: @@ -204,6 +232,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.17.2" + csv: + dependency: transitive + description: + name: csv + url: "https://pub.dartlang.org" + source: hosted + version: "5.0.1" cupertino_icons: dependency: "direct main" description: @@ -211,6 +246,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.5" + dart_code_metrics: + dependency: "direct dev" + description: + name: dart_code_metrics + url: "https://pub.dartlang.org" + source: hosted + version: "4.19.1" + dart_console2: + dependency: transitive + description: + name: dart_console2 + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" dart_style: dependency: transitive description: @@ -225,6 +274,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0" + dcli: + dependency: transitive + description: + name: dcli + url: "https://pub.dartlang.org" + source: hosted + version: "1.35.4" + dcli_core: + dependency: transitive + description: + name: dcli_core + url: "https://pub.dartlang.org" + source: hosted + version: "1.35.4" dio: dependency: "direct main" description: @@ -245,7 +308,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" ffi: dependency: transitive description: @@ -260,6 +323,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "6.1.4" + file_utils: + dependency: transitive + description: + name: file_utils + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" fixnum: dependency: transitive description: @@ -440,7 +510,7 @@ packages: name: frontend_server_client url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "3.1.0" get_it: dependency: "direct main" description: @@ -455,6 +525,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.0" + globbing: + dependency: transitive + description: + name: globbing + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" google_fonts: dependency: "direct main" description: @@ -504,6 +581,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.2.2" + ini: + dependency: transitive + description: + name: ini + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" intl: dependency: "direct main" description: @@ -587,7 +671,7 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" material_color_generator: dependency: "direct main" description: @@ -601,14 +685,14 @@ packages: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" mime: dependency: transitive description: @@ -643,7 +727,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" path_provider: dependency: transitive description: @@ -721,6 +805,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.3" + pointycastle: + dependency: transitive + description: + name: pointycastle + url: "https://pub.dartlang.org" + source: hosted + version: "3.6.2" pool: dependency: transitive description: @@ -728,6 +819,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.5.1" + posix: + dependency: transitive + description: + name: posix + url: "https://pub.dartlang.org" + source: hosted + version: "4.1.0" process: dependency: transitive description: @@ -749,6 +847,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.2" + pubspec2: + dependency: transitive + description: + name: pubspec2 + url: "https://pub.dartlang.org" + source: hosted + version: "2.4.1" pubspec_parse: dependency: transitive description: @@ -756,6 +861,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.1" + quiver: + dependency: transitive + description: + name: quiver + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" + random_string: + dependency: transitive + description: + name: random_string + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.1" rxdart: dependency: "direct main" description: @@ -763,6 +882,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.27.5" + scope: + dependency: transitive + description: + name: scope + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" + settings_yaml: + dependency: transitive + description: + name: settings_yaml + url: "https://pub.dartlang.org" + source: hosted + version: "3.5.0" shared_preferences: dependency: transitive description: @@ -858,7 +991,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.2" + version: "1.9.0" sprintf: dependency: transitive description: @@ -901,6 +1034,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.10.0" + stacktrace_impl: + dependency: transitive + description: + name: stacktrace_impl + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.0" stock: dependency: "direct main" description: @@ -928,7 +1068,7 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" strings: dependency: transitive description: @@ -943,20 +1083,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.0.0+3" + system_info2: + dependency: transitive + description: + name: system_info2 + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.4" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.9" + version: "0.4.12" time: dependency: transitive description: @@ -992,6 +1139,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.4" + uri: + dependency: transitive + description: + name: uri + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + uuid: + dependency: transitive + description: + name: uuid + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.6" + validators2: + dependency: transitive + description: + name: validators2 + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" vector_math: dependency: transitive description: @@ -999,6 +1167,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.2" + vin_decoder: + dependency: transitive + description: + name: vin_decoder + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.1-nullsafety" watcher: dependency: transitive description: @@ -1019,7 +1194,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "2.7.0" xdg_directories: dependency: transitive description: @@ -1042,5 +1217,5 @@ packages: source: hosted version: "3.1.1" sdks: - dart: ">=2.17.5 <3.0.0" - flutter: ">=3.0.5" + dart: ">=2.18.0 <3.0.0" + flutter: ">=3.3.6" diff --git a/pubspec.yaml b/pubspec.yaml index 4e7657d..4eaaaa3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,8 +6,8 @@ publish_to: 'none' version: 1.0.0+1 environment: - sdk: ">=2.17.0 <3.0.0" - flutter: 3.0.5 + sdk: ">=2.18.0 <3.0.0" + flutter: 3.3.6 # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions @@ -21,7 +21,6 @@ dependencies: flutter_localizations: sdk: flutter - arb_utils: ^0.3.0 auto_route: 5.0.2 bloc: 8.1.0 cupertino_icons: 1.0.5 @@ -49,8 +48,10 @@ dev_dependencies: flutter_test: sdk: flutter + arb_utils: 0.4.0 auto_route_generator: 5.0.2 - build_runner: 2.3.0 + build_runner: 2.3.2 + dart_code_metrics: 4.19.1 floor_generator: 1.3.0 flutter_flavorizr: 2.1.4 flutter_gen_runner: 5.0.2 @@ -78,7 +79,7 @@ flavorizr: bundleId: 'com.xmartlabs.template.dev' variables: FLUTTER_TARGET: - value: "lib/main.dart" + value: 'lib/main.dart' prod: app: name: 'Template' @@ -88,7 +89,7 @@ flavorizr: bundleId: 'com.xmartlabs.template' variables: FLUTTER_TARGET: - value: "lib/main.dart" + value: 'lib/main.dart' staging: app: name: 'Template Sta' @@ -98,7 +99,7 @@ flavorizr: bundleId: 'com.xmartlabs.template.sta' variables: FLUTTER_TARGET: - value: "lib/main.dart" + value: 'lib/main.dart' instructions: - assets:download - assets:extract diff --git a/scripts/checks.sh b/scripts/checks.sh index 37b5c84..c6c889b 100755 --- a/scripts/checks.sh +++ b/scripts/checks.sh @@ -3,7 +3,7 @@ RED='\033[0;31m' echo ':: Sorting translation files ::' -fvm flutter pub run arb_utils:sort lib/l10n/intl_en.arb; +fvm flutter pub run arb_utils sort lib/l10n/intl_en.arb; echo ':: Check code format ::' fvm flutter format --set-exit-if-changed . || { @@ -11,4 +11,12 @@ fvm flutter format --set-exit-if-changed . || { } echo ':: Run linter ::' -fvm flutter analyze . || { echo -e "${RED}Linter error" ; exit 1; } \ No newline at end of file +fvm flutter analyze . || { echo -e "${RED}Linter error" ; exit 1; } + +result=$(fvm flutter pub run dart_code_metrics:metrics analyze lib --fatal-style --fatal-performance --fatal-warnings) +echo "$result" +[[ $result == '✔ no issues found!' ]] || { echo -e "${RED}Linter error" ; exit 1; } + +fvm flutter pub run dart_code_metrics:metrics check-unused-code lib --fatal-unused || { echo -e "${RED}Linter error" ; exit 1; } + +fvm flutter pub run dart_code_metrics:metrics check-unused-files lib --fatal-unused || { echo -e "${RED}Linter error" ; exit 1; } diff --git a/scripts/regenerate_fastlane_docs.sh b/scripts/regenerate_fastlane_docs.sh new file mode 100755 index 0000000..77b08ab --- /dev/null +++ b/scripts/regenerate_fastlane_docs.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +fastlane fetch_dependencies +cd android && fastlane fetch_dependencies && cd - +cd ios && fastlane fetch_dependencies && cd -