@@ -967,40 +967,59 @@ class DefaultAssetPickerBuilderDelegate
967
967
return ;
968
968
}
969
969
final revert = effectiveShouldRevertGrid (context);
970
- List <AssetEntity > current;
970
+ // ignore: no_leading_underscores_for_local_identifiers
971
+ final int _debugFlow; // Only for debug process.
972
+ final List <AssetEntity > current;
971
973
final List <AssetEntity >? selected;
972
974
final int effectiveIndex;
973
975
if (isWeChatMoment) {
974
976
if (currentAsset.type == AssetType .video) {
975
977
current = < AssetEntity > [currentAsset];
976
978
selected = null ;
977
979
effectiveIndex = 0 ;
980
+ _debugFlow = 10 ;
978
981
} else {
982
+ final List <AssetEntity > list;
979
983
if (index == null ) {
980
- current = p.selectedAssets;
981
- current = current.reversed.toList (growable: false );
984
+ list = p.selectedAssets.reversed.toList (growable: false );
982
985
} else {
983
- current = p.currentAssets;
986
+ list = p.currentAssets;
984
987
}
985
- current = current
986
- .where ((AssetEntity e) => e.type == AssetType .image)
987
- .toList ();
988
+ current = list.where ((e) => e.type == AssetType .image).toList ();
988
989
selected = p.selectedAssets;
989
990
final i = current.indexOf (currentAsset);
990
991
effectiveIndex = revert ? current.length - i - 1 : i;
992
+ _debugFlow = switch ((index == null , revert)) {
993
+ (true , true ) => 21 ,
994
+ (true , false ) => 20 ,
995
+ (false , true ) => 31 ,
996
+ (false , false ) => 30 ,
997
+ };
991
998
}
992
999
} else {
993
1000
selected = p.selectedAssets;
1001
+ final List <AssetEntity > list;
994
1002
if (index == null ) {
995
- current = p.selectedAssets;
996
1003
if (revert) {
997
- current = current.reversed.toList (growable: false );
1004
+ list = p.selectedAssets.reversed.toList (growable: false );
1005
+ } else {
1006
+ list = p.selectedAssets;
998
1007
}
999
1008
effectiveIndex = selected.indexOf (currentAsset);
1009
+ current = list;
1000
1010
} else {
1001
1011
current = p.currentAssets;
1002
1012
effectiveIndex = revert ? current.length - index - 1 : index;
1003
1013
}
1014
+ _debugFlow = switch ((index == null , revert)) {
1015
+ (true , true ) => 41 ,
1016
+ (true , false ) => 40 ,
1017
+ (false , true ) => 51 ,
1018
+ (false , false ) => 50 ,
1019
+ };
1020
+ }
1021
+ if (current.isEmpty) {
1022
+ throw StateError ('Previewing empty assets is not allowed. $_debugFlow ' );
1004
1023
}
1005
1024
final List <AssetEntity >? result = await AssetPickerViewer .pushToViewer (
1006
1025
context,
0 commit comments