Skip to content

Commit 1e93ffe

Browse files
committed
Change ImageModel.name to nullable string
Null-coalesce to empty string where used
1 parent 7a7da9d commit 1e93ffe

7 files changed

Lines changed: 10 additions & 10 deletions

File tree

lib/components/cards/image_card.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class ImageCard extends StatelessWidget {
8080
end: Alignment.topCenter),
8181
),
8282
child: AutoSizeText(
83-
image.name,
83+
image.name ?? "",
8484
maxLines: 1,
8585
maxFontSize: 14,
8686
minFontSize: 8,

lib/components/dialogs/image_comment_dialog.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class _ImageCommentDialogState extends State<ImageCommentDialog> {
5959
curve: Curves.ease,
6060
opacity: isNameHidden ? 1.0 : 0.0,
6161
child: Text(
62-
widget.image.name,
62+
widget.image.name ?? "",
6363
maxLines: 1,
6464
overflow: TextOverflow.ellipsis,
6565
style: Theme.of(context).textTheme.titleMedium,
@@ -78,7 +78,7 @@ class _ImageCommentDialogState extends State<ImageCommentDialog> {
7878
crossAxisAlignment: CrossAxisAlignment.stretch,
7979
children: [
8080
Text(
81-
widget.image.name,
81+
widget.image.name ?? "",
8282
textAlign: TextAlign.center,
8383
style: Theme.of(context).textTheme.titleMedium,
8484
),

lib/components/modals/image_info_modal.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ImageInfoModal extends StatelessWidget {
4545
Padding(
4646
padding: const EdgeInsets.all(8.0),
4747
child: Text(
48-
image.name,
48+
image.name ?? "",
4949
style: Theme.of(context).textTheme.titleMedium,
5050
),
5151
),

lib/models/image_model.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class ImageModel {
88
int hit;
99
bool favorite;
1010
String file;
11-
String name;
11+
String? name;
1212
String? comment;
1313
String? dateCreation;
1414
String? dateAvailable;
@@ -25,7 +25,7 @@ class ImageModel {
2525
this.hit = 0,
2626
this.favorite = false,
2727
this.file = '',
28-
required this.name,
28+
this.name,
2929
this.comment,
3030
this.dateCreation,
3131
this.dateAvailable,
@@ -43,7 +43,7 @@ class ImageModel {
4343
hit = int.tryParse(json['hit'].toString()) ?? 0,
4444
favorite = json['is_favorite'] ?? false,
4545
file = json['file'].toString(),
46-
name = json['name'].toString(),
46+
name = json['name']?.toString(),
4747
comment = json['comment'],
4848
dateCreation = json['date_creation'],
4949
dateAvailable = json['date_available'],

lib/utils/image_actions.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ Future<dynamic> onMovePhotos(BuildContext context, List<ImageModel> images,
188188
title: appStrings.moveImage_title,
189189
subtitle: appStrings.moveImage_selectAlbum(
190190
images.length,
191-
images.first.name,
191+
images.first.name ?? "",
192192
),
193193
isImage: true,
194194
album: origin,

lib/views/image/edit_image_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class _EditImagePageState extends State<EditImagePage> {
5151
_authorController =
5252
TextEditingController(text: Preferences.getUploadAuthor);
5353
if (_imageList.length == 1) {
54-
_titleController.text = _imageList.first.name;
54+
_titleController.text = _imageList.first.name ?? "";
5555
_descriptionController.text = _imageList.first.comment ?? '';
5656
_tags = _imageList.first.tags;
5757
}

lib/views/image/image_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ class _ImagePageState extends State<ImagePage> {
345345
),
346346
Expanded(
347347
child: AutoSizeText(
348-
'${_currentImage.name}',
348+
'${_currentImage.name ?? ""}',
349349
softWrap: true,
350350
maxLines: 1,
351351
maxFontSize: 16.0,

0 commit comments

Comments
 (0)