Skip to content

Commit

Permalink
Merge pull request #36 from ryanaidilp/hotfix/0.6.3
Browse files Browse the repository at this point in the history
fix: fatal bug in Infographics
  • Loading branch information
ryanaidilp authored Oct 1, 2023
2 parents a59f908 + 5988874 commit a59160d
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 91 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions example/lib/app/shared/widgets/infographic_card.dart
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
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 {
const InfographicCard({
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(
Expand Down Expand Up @@ -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,
),
Expand Down
128 changes: 64 additions & 64 deletions lib/src/config/env.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions lib/src/core/di/service_locator.config.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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<String, dynamic> json) =>
_$InfographicModelFromJson(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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});
}
Expand All @@ -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,
}) {
Expand All @@ -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
Expand All @@ -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});
}
Expand All @@ -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,
}) {
Expand All @@ -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
Expand All @@ -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});

Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand All @@ -41,7 +41,7 @@ class Infographic extends Equatable {
final String downloadUrl;

@override
List<Object> get props {
List<Object?> get props {
return [
id,
title,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a59160d

Please sign in to comment.