diff --git a/CHANGELOG.md b/CHANGELOG.md index 1964cf1c..38f225d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.6.3+15 + +> 2023-10-01 + +### Fixed + +- **Fixed** crash causing by `Infographic` not handling null description case. + ## 0.6.2+14 > 2023-10-01 diff --git a/example/lib/app/shared/widgets/infographic_card.dart b/example/lib/app/shared/widgets/infographic_card.dart index 6943a8b6..f99a1676 100644 --- a/example/lib/app/shared/widgets/infographic_card.dart +++ b/example/lib/app/shared/widgets/infographic_card.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:intl/intl.dart'; import 'package:stadata_example/app/shared/widgets/network_image.dart'; class InfographicCard extends StatelessWidget { @@ -7,14 +8,14 @@ class InfographicCard extends StatelessWidget { super.key, required this.title, required this.image, - required this.description, + this.description, }); final String title; final String image; - final String description; + final String? description; @override Widget build(BuildContext context) => Stack( @@ -56,7 +57,9 @@ class InfographicCard extends StatelessWidget { overflow: TextOverflow.ellipsis, ), Text( - description.isEmpty ? '---' : description, + description == null || description!.isEmpty + ? '---' + : Bidi.stripHtmlIfNeeded(description!), style: Theme.of(context).textTheme.bodyMedium?.copyWith( color: Colors.white, ), diff --git a/lib/src/config/env.g.dart b/lib/src/config/env.g.dart index 0d02c536..48341f71 100644 --- a/lib/src/config/env.g.dart +++ b/lib/src/config/env.g.dart @@ -8,72 +8,72 @@ part of 'env.dart'; class _Env { static const List _enviedkeyapiBaseUrl = [ - 427538107, - 3556360021, - 2633568968, - 354283219, - 563155355, - 1515977920, - 1157958027, - 559702428, - 2250425028, - 1689193706, - 2194611420, - 3112398407, - 2990856531, - 2088214361, - 18730107, - 3300493445, - 3268242660, - 4171169086, - 2148211119, - 2566513579, - 339536734, - 712942251, - 995786571, - 3089066917, - 3777695356, - 3698008569, - 2195927187, - 3884289861, - 747002592, - 3458617067, - 2347359752, - 2021764351 + 3041188094, + 685977008, + 3970431083, + 2157240091, + 1373868596, + 3693764033, + 2597687811, + 3059444966, + 1385735035, + 3445578875, + 4101094800, + 1819525675, + 2000876093, + 3418006712, + 3420668353, + 3646717373, + 3381247573, + 3973063312, + 2681961234, + 1530546812, + 3575533093, + 324154921, + 2779009074, + 1249896861, + 3610762308, + 2263305006, + 392449273, + 1523845689, + 2476908386, + 322692344, + 3961205719, + 1946266707 ]; static const List _envieddataapiBaseUrl = [ - 427538131, - 3556359969, - 2633568956, - 354283171, - 563155432, - 1515977978, - 1157958052, - 559702451, - 2250425011, - 1689193615, - 2194611390, - 3112398374, - 2990856483, - 2088214320, - 18730069, - 3300493543, - 3268242580, - 4171169101, - 2148211073, - 2566513612, - 339536689, - 712942213, - 995786530, - 3089066945, - 3777695315, - 3698008463, - 2195927202, - 3884289898, - 747002497, - 3458616987, - 2347359841, - 2021764304 + 3041187990, + 685977028, + 3970431007, + 2157240171, + 1373868615, + 3693764091, + 2597687852, + 3059444937, + 1385734924, + 3445578782, + 4101094898, + 1819525706, + 2000876109, + 3418006737, + 3420668399, + 3646717407, + 3381247525, + 3973063395, + 2681961276, + 1530546715, + 3575533130, + 324154887, + 2779009115, + 1249896953, + 3610762347, + 2263305048, + 392449224, + 1523845654, + 2476908291, + 322692232, + 3961205694, + 1946266748 ]; static final String apiBaseUrl = String.fromCharCodes( List.generate(_envieddataapiBaseUrl.length, (i) => i, growable: false) diff --git a/lib/src/core/di/service_locator.config.dart b/lib/src/core/di/service_locator.config.dart index a1ed9b81..fda26874 100644 --- a/lib/src/core/di/service_locator.config.dart +++ b/lib/src/core/di/service_locator.config.dart @@ -143,15 +143,15 @@ _i1.GetIt $initGetIt( gh.lazySingleton<_i18.GetDetailStaticTable>( () => _i18.GetDetailStaticTable()); gh.lazySingleton<_i19.GetDomains>(() => _i19.GetDomains()); - gh.factory<_i20.HttpClient>( - () => registerModule.listHttpClient, - instanceName: 'listClient', - ); + gh.factory<_i20.HttpClient>(() => registerModule.httpClient); gh.factory<_i20.HttpClient>( () => registerModule.viewHttpClient, instanceName: 'viewClient', ); - gh.factory<_i20.HttpClient>(() => registerModule.httpClient); + gh.factory<_i20.HttpClient>( + () => registerModule.listHttpClient, + instanceName: 'listClient', + ); gh.lazySingleton<_i21.InfographicRemoteDataSource>( () => _i21.InfographicRemoteDataSourceImpl()); gh.lazySingleton<_i22.InfographicRepository>( diff --git a/lib/src/features/infographics/data/models/infographic_model.dart b/lib/src/features/infographics/data/models/infographic_model.dart index 03d3351e..e1c703d8 100644 --- a/lib/src/features/infographics/data/models/infographic_model.dart +++ b/lib/src/features/infographics/data/models/infographic_model.dart @@ -12,9 +12,9 @@ abstract class InfographicModel with _$InfographicModel { @JsonKey(name: 'inf_id') required int id, required String title, @JsonKey(name: 'img') required String image, - @JsonKey(name: 'desc') required String description, required int category, @JsonKey(name: 'dl') required String downloadUrl, + @JsonKey(name: 'desc') String? description, }) = _InfographicModel; factory InfographicModel.fromJson(Map json) => _$InfographicModelFromJson(json); diff --git a/lib/src/features/infographics/data/models/infographic_model.freezed.dart b/lib/src/features/infographics/data/models/infographic_model.freezed.dart index 2e7271d7..0b6ba8f8 100644 --- a/lib/src/features/infographics/data/models/infographic_model.freezed.dart +++ b/lib/src/features/infographics/data/models/infographic_model.freezed.dart @@ -26,7 +26,7 @@ mixin _$InfographicModel { @JsonKey(name: 'img') String get image => throw _privateConstructorUsedError; @JsonKey(name: 'desc') - String get description => throw _privateConstructorUsedError; + String? get description => throw _privateConstructorUsedError; int get category => throw _privateConstructorUsedError; @JsonKey(name: 'dl') String get downloadUrl => throw _privateConstructorUsedError; @@ -47,7 +47,7 @@ abstract class $InfographicModelCopyWith<$Res> { {@JsonKey(name: 'inf_id') int id, String title, @JsonKey(name: 'img') String image, - @JsonKey(name: 'desc') String description, + @JsonKey(name: 'desc') String? description, int category, @JsonKey(name: 'dl') String downloadUrl}); } @@ -68,7 +68,7 @@ class _$InfographicModelCopyWithImpl<$Res, $Val extends InfographicModel> Object? id = null, Object? title = null, Object? image = null, - Object? description = null, + Object? description = freezed, Object? category = null, Object? downloadUrl = null, }) { @@ -85,10 +85,10 @@ class _$InfographicModelCopyWithImpl<$Res, $Val extends InfographicModel> ? _value.image : image // ignore: cast_nullable_to_non_nullable as String, - description: null == description + description: freezed == description ? _value.description : description // ignore: cast_nullable_to_non_nullable - as String, + as String?, category: null == category ? _value.category : category // ignore: cast_nullable_to_non_nullable @@ -113,7 +113,7 @@ abstract class _$$_InfographicModelCopyWith<$Res> {@JsonKey(name: 'inf_id') int id, String title, @JsonKey(name: 'img') String image, - @JsonKey(name: 'desc') String description, + @JsonKey(name: 'desc') String? description, int category, @JsonKey(name: 'dl') String downloadUrl}); } @@ -132,7 +132,7 @@ class __$$_InfographicModelCopyWithImpl<$Res> Object? id = null, Object? title = null, Object? image = null, - Object? description = null, + Object? description = freezed, Object? category = null, Object? downloadUrl = null, }) { @@ -149,10 +149,10 @@ class __$$_InfographicModelCopyWithImpl<$Res> ? _value.image : image // ignore: cast_nullable_to_non_nullable as String, - description: null == description + description: freezed == description ? _value.description : description // ignore: cast_nullable_to_non_nullable - as String, + as String?, category: null == category ? _value.category : category // ignore: cast_nullable_to_non_nullable @@ -172,7 +172,7 @@ class _$_InfographicModel implements _InfographicModel { {@JsonKey(name: 'inf_id') required this.id, required this.title, @JsonKey(name: 'img') required this.image, - @JsonKey(name: 'desc') required this.description, + @JsonKey(name: 'desc') this.description, required this.category, @JsonKey(name: 'dl') required this.downloadUrl}); @@ -189,7 +189,7 @@ class _$_InfographicModel implements _InfographicModel { final String image; @override @JsonKey(name: 'desc') - final String description; + final String? description; @override final int category; @override @@ -241,7 +241,7 @@ abstract class _InfographicModel implements InfographicModel { {@JsonKey(name: 'inf_id') required final int id, required final String title, @JsonKey(name: 'img') required final String image, - @JsonKey(name: 'desc') required final String description, + @JsonKey(name: 'desc') final String? description, required final int category, @JsonKey(name: 'dl') required final String downloadUrl}) = _$_InfographicModel; @@ -259,7 +259,7 @@ abstract class _InfographicModel implements InfographicModel { String get image; @override @JsonKey(name: 'desc') - String get description; + String? get description; @override int get category; @override diff --git a/lib/src/features/infographics/data/models/infographic_model.g.dart b/lib/src/features/infographics/data/models/infographic_model.g.dart index 454518ff..cb2e4c6b 100644 --- a/lib/src/features/infographics/data/models/infographic_model.g.dart +++ b/lib/src/features/infographics/data/models/infographic_model.g.dart @@ -11,7 +11,7 @@ _$_InfographicModel _$$_InfographicModelFromJson(Map json) => id: json['inf_id'] as int, title: json['title'] as String, image: json['img'] as String, - description: json['desc'] as String, + description: json['desc'] as String?, category: json['category'] as int, downloadUrl: json['dl'] as String, ); diff --git a/lib/src/features/infographics/domain/entities/infographic.dart b/lib/src/features/infographics/domain/entities/infographic.dart index 3ecd7619..38449a42 100644 --- a/lib/src/features/infographics/domain/entities/infographic.dart +++ b/lib/src/features/infographics/domain/entities/infographic.dart @@ -17,9 +17,9 @@ class Infographic extends Equatable { required this.id, required this.title, required this.image, - required this.description, required this.category, required this.downloadUrl, + this.description, }); /// The unique identifier of the infographic. @@ -32,7 +32,7 @@ class Infographic extends Equatable { final String image; /// A brief description or summary of the infographic's content. - final String description; + final String? description; /// The category or topic to which the infographic belongs. final int category; @@ -41,7 +41,7 @@ class Infographic extends Equatable { final String downloadUrl; @override - List get props { + List get props { return [ id, title, diff --git a/pubspec.yaml b/pubspec.yaml index b4028324..4cbe2411 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: | Streamline BPS Statistics API integration in Flutter. Easily fetch, analyze, and visualize data. homepage: https://ryanaidilp.github.io/stadata-flutter-sdk-docs/ repository: https://github.com/ryanaidilp/stadata_flutter_sdk -version: 0.6.2+14 +version: 0.6.3+15 # publish_to: none environment: