Skip to content

Commit 4c14977

Browse files
Merge pull request #185 from astarub/ui-fixes
Add null checks to calendar entities
2 parents 03c664f + 7207988 commit 4c14977

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

lib/pages/calendar/entities/event_entity.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ class Event {
148148
id: json['id'],
149149
url: json['url'],
150150
title: json['title'],
151-
description: json['description'],
152-
slug: json['slug'],
151+
description: json['description'] ?? '',
152+
slug: json['slug'] ?? '',
153153
hasImage: hasImage,
154154
imageUrl: hasImage ? (json['image'] as Map<String, dynamic>)['url'] : null,
155155
startDate: DateFormat('yyyy-MM-dd HH:mm:ss Z', 'de_DE').parse(
@@ -158,13 +158,13 @@ class Event {
158158
endDate: DateFormat('yyyy-MM-dd HH:mm:ss Z', 'de_DE').parse(
159159
"${json['end_date']} ${json['timezone']}",
160160
),
161-
allDay: json['all_day'],
161+
allDay: json['all_day'] ?? false,
162162
cost: cost,
163-
website: json['website'],
163+
website: json['website'] ?? '',
164164
categories: categories,
165165
venue: venue,
166166
organizers: organizers,
167-
author: json['author'],
167+
author: json['author'] ?? '',
168168
pinned: json['pinned'] ?? false,
169169
);
170170
}

lib/pages/calendar/entities/organizer_entity.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ class Organizer {
4949
final email = json.containsKey('email') ? json['email'] : null;
5050

5151
return Organizer(
52-
id: json['id'],
53-
name: json['organizer'],
54-
url: json['url'],
55-
slug: json['slug'],
52+
id: json['id'] ?? -1,
53+
name: json['organizer'] ?? '',
54+
url: json['url'] ?? '',
55+
slug: json['slug'] ?? '',
5656
phone: phone,
5757
website: website,
5858
email: email,

lib/pages/calendar/entities/venue_entity.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ class Venue {
6868
final phone = json.containsKey('phone') ? json['phone'] : null;
6969

7070
return Venue(
71-
id: json['id'],
72-
name: json['venue'],
73-
url: json['url'],
74-
slug: json['slug'],
71+
id: json['id'] ?? '',
72+
name: json['venue'] ?? '',
73+
url: json['url'] ?? '',
74+
slug: json['slug'] ?? '',
7575
address: address,
7676
city: city,
7777
country: country,

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: campus_app
22
description: Simplifie, improve and facilitate everyday students life.
33
publish_to: 'none'
4-
version: 2.3.3
4+
version: 2.3.4
55

66
environment:
77
sdk: ">=3.5.0 <4.0.0"

0 commit comments

Comments
 (0)