computeDy method
Implementation
@override
double computeDy(List<AnimatedSnackBar> snackBars, AnimatedSnackBar self) {
final index = snackBars.indexWhere(
(element) => element.info.key.currentContext != null,
);
if (index != -1) {
bool isDesktop =
MediaQuery.of(snackBars[index].info.key.currentContext!).size.width >
600;
final olderBars = snackBars.where(
(element) {
bool isMobileAndSamePosition =
(element.mobileSnackBarPosition == self.mobileSnackBarPosition &&
!isDesktop);
bool isDesktopAndSamePosition = (element.desktopSnackBarPosition ==
self.desktopSnackBarPosition &&
isDesktop);
return (isMobileAndSamePosition || isDesktopAndSamePosition) &&
(element.info.key.currentState?.isVisible ?? false) &&
element.info.createdAt.isBefore(self.info.createdAt);
},
).toList();
return olderBars.fold<double>(0, (initialValue, element) {
final box =
element.info.key.currentContext!.findRenderObject() as RenderBox;
return initialValue + box.size.height + gap;
});
}
return 0;
}