Skip to content

Commit 3d8f331

Browse files
committed
Remove shouldBuildSpecialItem.
1 parent 750dd16 commit 3d8f331

File tree

3 files changed

+33
-75
lines changed

3 files changed

+33
-75
lines changed

example/lib/customs/pickers/insta_asset_picker.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,7 @@ class InstaAssetPickerBuilder extends DefaultAssetPickerBuilderDelegate {
673673
appBarPreferredSize ??= appBar(context).preferredSize;
674674
return Consumer<DefaultAssetPickerProvider>(
675675
builder: (BuildContext context, DefaultAssetPickerProvider p, __) {
676-
final bool shouldDisplayAssets =
677-
p.hasAssetsToDisplay || shouldBuildSpecialItem;
676+
final bool shouldDisplayAssets = p.hasAssetsToDisplay;
678677
_initializePreviewAsset(p, shouldDisplayAssets);
679678

680679
return AnimatedSwitcher(

example/lib/customs/pickers/multi_tabs_assets_picker.dart

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -518,30 +518,19 @@ class MultiTabAssetPickerBuilder extends DefaultAssetPickerBuilderDelegate {
518518
}
519519

520520
Widget _buildGrid(BuildContext context) {
521-
return Consumer<DefaultAssetPickerProvider>(
522-
builder: (BuildContext context, DefaultAssetPickerProvider p, __) {
523-
final bool shouldDisplayAssets =
524-
p.hasAssetsToDisplay || shouldBuildSpecialItem;
525-
return AnimatedSwitcher(
526-
duration: const Duration(milliseconds: 300),
527-
child: shouldDisplayAssets
528-
? Stack(
529-
children: <Widget>[
530-
RepaintBoundary(
531-
child: Column(
532-
children: <Widget>[
533-
Expanded(child: assetsGridBuilder(context)),
534-
bottomActionBar(context),
535-
],
536-
),
537-
),
538-
pathEntityListBackdrop(context),
539-
pathEntityListWidget(context),
540-
],
541-
)
542-
: loadingIndicator(context),
543-
);
544-
},
521+
return Stack(
522+
children: <Widget>[
523+
RepaintBoundary(
524+
child: Column(
525+
children: <Widget>[
526+
Expanded(child: assetsGridBuilder(context)),
527+
bottomActionBar(context),
528+
],
529+
),
530+
),
531+
pathEntityListBackdrop(context),
532+
pathEntityListWidget(context),
533+
],
545534
);
546535
}
547536

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 19 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,6 @@ abstract class AssetPickerBuilderDelegate<Asset, Path> {
176176
/// 选择器是否为单选模式
177177
bool get isSingleAssetMode;
178178

179-
/// Whether the delegate should build the special item.
180-
/// 是否需要构建自定义 item
181-
bool get shouldBuildSpecialItem => specialItems.isNotEmpty;
182-
183179
/// Space between assets item widget.
184180
/// 资源部件之间的间隔
185181
double get itemSpacing => 2;
@@ -1121,30 +1117,19 @@ class DefaultAssetPickerBuilderDelegate
11211117
Widget androidLayout(BuildContext context) {
11221118
return AssetPickerAppBarWrapper(
11231119
appBar: appBar(context),
1124-
body: Consumer<DefaultAssetPickerProvider>(
1125-
builder: (BuildContext context, DefaultAssetPickerProvider p, _) {
1126-
final bool shouldDisplayAssets =
1127-
p.hasAssetsToDisplay || shouldBuildSpecialItem;
1128-
return AnimatedSwitcher(
1129-
duration: switchingPathDuration,
1130-
child: shouldDisplayAssets
1131-
? Stack(
1132-
children: <Widget>[
1133-
RepaintBoundary(
1134-
child: Column(
1135-
children: <Widget>[
1136-
Expanded(child: assetsGridBuilder(context)),
1137-
bottomActionBar(context),
1138-
],
1139-
),
1140-
),
1141-
pathEntityListBackdrop(context),
1142-
pathEntityListWidget(context),
1143-
],
1144-
)
1145-
: loadingIndicator(context),
1146-
);
1147-
},
1120+
body: Stack(
1121+
children: <Widget>[
1122+
RepaintBoundary(
1123+
child: Column(
1124+
children: <Widget>[
1125+
Expanded(child: assetsGridBuilder(context)),
1126+
bottomActionBar(context),
1127+
],
1128+
),
1129+
),
1130+
pathEntityListBackdrop(context),
1131+
pathEntityListWidget(context),
1132+
],
11481133
),
11491134
);
11501135
}
@@ -1172,27 +1157,12 @@ class DefaultAssetPickerBuilderDelegate
11721157
return Stack(
11731158
children: <Widget>[
11741159
Positioned.fill(
1175-
child: Consumer<DefaultAssetPickerProvider>(
1176-
builder: (_, DefaultAssetPickerProvider p, __) {
1177-
final Widget child;
1178-
final bool shouldDisplayAssets =
1179-
p.hasAssetsToDisplay || shouldBuildSpecialItem;
1180-
if (shouldDisplayAssets) {
1181-
child = Stack(
1182-
children: <Widget>[
1183-
gridLayout(context),
1184-
pathEntityListBackdrop(context),
1185-
pathEntityListWidget(context),
1186-
],
1187-
);
1188-
} else {
1189-
child = loadingIndicator(context);
1190-
}
1191-
return AnimatedSwitcher(
1192-
duration: switchingPathDuration,
1193-
child: child,
1194-
);
1195-
},
1160+
child: Stack(
1161+
children: <Widget>[
1162+
gridLayout(context),
1163+
pathEntityListBackdrop(context),
1164+
pathEntityListWidget(context),
1165+
],
11961166
),
11971167
),
11981168
appBar(context),

0 commit comments

Comments
 (0)