copyWith should create new instances of collections

This commit is contained in:
Ming Ming 2021-12-20 02:27:40 +08:00
parent b5685d1d65
commit 2bddfcbf8c
4 changed files with 8 additions and 6 deletions

View file

@ -36,7 +36,7 @@ class Account with EquatableMixin {
address ?? this.address,
username ?? this.username,
password ?? this.password,
roots ?? _roots,
roots ?? List.of(_roots),
);
}

View file

@ -117,7 +117,7 @@ class ListSharingBlocSuccess extends ListSharingBlocState {
}) =>
ListSharingBlocSuccess(
account ?? this.account,
items ?? this.items,
items ?? List.of(this.items),
);
}
@ -141,7 +141,7 @@ class ListSharingBlocFailure extends ListSharingBlocState {
}) =>
ListSharingBlocFailure(
account ?? this.account,
items ?? this.items,
items ?? List.of(this.items),
exception ?? this.exception,
);

View file

@ -17,6 +17,7 @@ import 'package:nc_photos/entity/file/data_source.dart';
import 'package:nc_photos/exception.dart';
import 'package:nc_photos/int_util.dart' as int_util;
import 'package:nc_photos/iterable_extension.dart';
import 'package:nc_photos/object_extension.dart';
import 'package:nc_photos/or_null.dart';
import 'package:nc_photos/remote_storage_util.dart' as remote_storage_util;
import 'package:nc_photos/type.dart';
@ -154,7 +155,8 @@ class Album with EquatableMixin {
provider: provider ?? this.provider,
coverProvider: coverProvider ?? this.coverProvider,
sortProvider: sortProvider ?? this.sortProvider,
shares: shares == null ? this.shares : shares.obj,
shares:
shares == null ? this.shares?.run((obj) => List.of(obj)) : shares.obj,
albumFile: albumFile == null ? this.albumFile : albumFile.obj,
savedVersion: savedVersion,
);

View file

@ -141,7 +141,7 @@ class AlbumStaticProvider extends AlbumProviderBase {
return AlbumStaticProvider(
latestItemTime:
latestItemTime == null ? this.latestItemTime : latestItemTime.obj,
items: items ?? this.items,
items: items ?? List.of(this.items),
);
}
@ -206,7 +206,7 @@ class AlbumDirProvider extends AlbumDynamicProvider {
return AlbumDirProvider(
latestItemTime:
latestItemTime == null ? this.latestItemTime : latestItemTime.obj,
dirs: dirs ?? this.dirs,
dirs: dirs ?? List.of(this.dirs),
);
}