From 2743daa67e20d35a3fc28a70e8e45c37eacc0fdf Mon Sep 17 00:00:00 2001 From: wheremyfiji Date: Sun, 21 Jul 2024 19:31:35 +0300 Subject: [PATCH] dev --- analysis_options.yaml | 12 ++++++++++ .../anime_details_new_page.dart | 22 ++++++++++--------- .../anime_details_new/graphql_anime.dart | 5 +++-- .../anime_database_service.dart | 11 ++++++---- lib/src/services/http/dio_service.dart | 10 +++++++-- 5 files changed, 42 insertions(+), 18 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 6f3ef08..c66bbf0 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -5,10 +5,22 @@ # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be # invoked from the command line by running `flutter analyze`. +# https://dart.dev/tools/analysis#enabling-linter-rules + # 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 +analyzer: + exclude: + - '.dart_tool/**' + - 'build/**' + - '**.g.dart' + - '**/*.g.dart' + - '**/*.config.dart' + - '**/*.gen.dart' + - '**/*.freezed.dart' + 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` diff --git a/lib/src/presentation/pages/anime_details_new/anime_details_new_page.dart b/lib/src/presentation/pages/anime_details_new/anime_details_new_page.dart index 67d091a..5bca2a6 100644 --- a/lib/src/presentation/pages/anime_details_new/anime_details_new_page.dart +++ b/lib/src/presentation/pages/anime_details_new/anime_details_new_page.dart @@ -288,17 +288,19 @@ class _AnimeDetailsNewPageState extends ConsumerState { ], ), ), - const SliverToBoxAdapter( - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 16.0), - child: Divider(), + if (title.topic != null) ...[ + const SliverToBoxAdapter( + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 16.0), + child: Divider(), + ), ), - ), - TitleComments( - id: title.topic.id, - count: title.topic.commentsCount, - name: title.russian ?? title.name, - ), + TitleComments( + id: title.topic!.id, + count: title.topic!.commentsCount, + name: title.russian ?? title.name, + ), + ], ]; }, loading: () => [ diff --git a/lib/src/presentation/pages/anime_details_new/graphql_anime.dart b/lib/src/presentation/pages/anime_details_new/graphql_anime.dart index 9deba6e..34e9023 100644 --- a/lib/src/presentation/pages/anime_details_new/graphql_anime.dart +++ b/lib/src/presentation/pages/anime_details_new/graphql_anime.dart @@ -260,7 +260,7 @@ class GraphqlAnime { final String name; final String url; final Poster poster; - final GraphqlTopic topic; + final GraphqlTopic? topic; final String? russian; final String? english; final String? japanese; @@ -331,7 +331,8 @@ class GraphqlAnime { name: json["name"], url: json["url"], poster: Poster.fromJson(json["poster"]), - topic: GraphqlTopic.fromJson(json["topic"]), + topic: + json["topic"] == null ? null : GraphqlTopic.fromJson(json["topic"]), russian: json["russian"], english: json["english"], japanese: json["japanese"], diff --git a/lib/src/services/anime_database/anime_database_service.dart b/lib/src/services/anime_database/anime_database_service.dart index 01b87ef..531c560 100644 --- a/lib/src/services/anime_database/anime_database_service.dart +++ b/lib/src/services/anime_database/anime_database_service.dart @@ -2,14 +2,16 @@ import 'dart:developer'; import 'dart:convert' as c; import 'dart:io' as io; +import 'package:flutter/foundation.dart'; + +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:path_provider/path_provider.dart' as path_prov; +import 'package:sentry_flutter/sentry_flutter.dart'; +import 'package:url_launcher/url_launcher.dart'; import 'package:collection/collection.dart'; import 'package:intl/intl.dart'; import 'package:isar/isar.dart'; -import 'package:path_provider/path_provider.dart' as path_prov; import 'package:path/path.dart' as p; -import 'package:shared_preferences/shared_preferences.dart'; -import 'package:url_launcher/url_launcher.dart'; -import 'package:sentry_flutter/sentry_flutter.dart'; import '../../constants/config.dart'; import '../../data/repositories/anime_database_repo.dart'; @@ -27,6 +29,7 @@ class LocalAnimeDatabaseImpl implements LocalAnimeDatabaseRepo { [AnimeDatabaseSchema], name: "animeDatabase", directory: appDocDir.path, + inspector: kDebugMode, //compactOnLaunch: const CompactCondition(minRatio: 2.0), ), ); diff --git a/lib/src/services/http/dio_service.dart b/lib/src/services/http/dio_service.dart index 60be625..0f264c9 100644 --- a/lib/src/services/http/dio_service.dart +++ b/lib/src/services/http/dio_service.dart @@ -1,5 +1,6 @@ import 'dart:developer'; +import 'package:dio_http2_adapter/dio_http2_adapter.dart'; import 'package:native_dio_adapter/native_dio_adapter.dart'; import 'package:dio_smart_retry/dio_smart_retry.dart'; import 'package:network_logger/network_logger.dart'; @@ -22,15 +23,20 @@ class DioHttpService implements HttpService { dio.httpClientAdapter = NativeAdapter( createCronetEngine: () { return CronetEngine.build( - // enableQuic: true, enableHttp2: true, enableBrotli: true, cacheMode: CacheMode.memory, - cacheMaxSize: 4 * 1024 * 1024, + cacheMaxSize: 5 * 1024 * 1024, userAgent: AppUtils.instance.userAgent, ); }, ); + } else { + dio.httpClientAdapter = Http2Adapter( + ConnectionManager( + idleTimeout: const Duration(seconds: 10), + ), + ); } dio.interceptors.add(RetryInterceptor(