Skip to content

Commit 2002882

Browse files
committed
🐛 Two fixes:
- Fix path entity nullable issues with the asset grid - Fix assets displaying condition missing with the iOS layout
1 parent 5c45301 commit 2002882

File tree

1 file changed

+31
-25
lines changed

1 file changed

+31
-25
lines changed

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -769,32 +769,37 @@ class DefaultAssetPickerBuilderDelegate
769769
Positioned.fill(
770770
child: Selector<DefaultAssetPickerProvider, bool>(
771771
selector: (_, DefaultAssetPickerProvider p) => p.hasAssetsToDisplay,
772-
builder: (_, bool hasAssetsToDisplay, __) => AnimatedSwitcher(
773-
duration: switchingPathDuration,
774-
child: hasAssetsToDisplay
775-
? Stack(
776-
children: <Widget>[
777-
RepaintBoundary(
778-
child: Stack(
779-
children: <Widget>[
780-
Positioned.fill(
781-
child: assetsGridBuilder(context),
782-
),
783-
if ((!isSingleAssetMode || isAppleOS) &&
784-
isPreviewEnabled)
772+
builder: (_, bool hasAssetsToDisplay, __) {
773+
final bool shouldDisplayAssets = hasAssetsToDisplay ||
774+
(allowSpecialItemWhenEmpty &&
775+
specialItemPosition != SpecialItemPosition.none);
776+
return AnimatedSwitcher(
777+
duration: switchingPathDuration,
778+
child: shouldDisplayAssets
779+
? Stack(
780+
children: <Widget>[
781+
RepaintBoundary(
782+
child: Stack(
783+
children: <Widget>[
785784
Positioned.fill(
786-
top: null,
787-
child: bottomActionBar(context),
785+
child: assetsGridBuilder(context),
788786
),
789-
],
787+
if ((!isSingleAssetMode || isAppleOS) &&
788+
isPreviewEnabled)
789+
Positioned.fill(
790+
top: null,
791+
child: bottomActionBar(context),
792+
),
793+
],
794+
),
790795
),
791-
),
792-
pathEntityListBackdrop(context),
793-
pathEntityListWidget(context),
794-
],
795-
)
796-
: loadingIndicator(context),
797-
),
796+
pathEntityListBackdrop(context),
797+
pathEntityListWidget(context),
798+
],
799+
)
800+
: loadingIndicator(context),
801+
);
802+
},
798803
),
799804
),
800805
appBar(context),
@@ -808,9 +813,10 @@ class DefaultAssetPickerBuilderDelegate
808813
selector: (_, DefaultAssetPickerProvider p) => p.currentPathEntity,
809814
builder: (_, AssetPathEntity? path, __) {
810815
// First, we need the count of the assets.
811-
int totalCount = path!.assetCount;
816+
int totalCount = path?.assetCount ?? 0;
812817
// If user chose a special item's position, add 1 count.
813-
if (specialItemPosition != SpecialItemPosition.none && path.isAll) {
818+
if (specialItemPosition != SpecialItemPosition.none &&
819+
path?.isAll == true) {
814820
totalCount += 1;
815821
}
816822
// Then we use the [totalCount] to calculate how many placeholders we need.

0 commit comments

Comments
 (0)