I am using https://pub.dev/packages/persistent_bottom_nav_bar package to show bottom bar. I need to open bottom sheet when one of the bottom bar tab pressed. I have managed to show bottom sheet using showModalBottomSheet, but problem is it covers existing bottom bar. I need to open bottom sheet above bottom bar instead of from bottom of screen. This is what i want to achieve.
So I managed to show using showGeneralDialog with Container and bottom margin. Below is my solution.
showGeneralDialog(
barrierLabel: AppLocalizations.of(context).translate(LanguageConstant.more),
barrierDismissible: true,
barrierColor: Colors.grey.withOpacity(0.1),
transitionDuration: Duration(milliseconds: 100),
context: context,
pageBuilder: (dialogContext, anim1, anim2) {
return Align(
alignment: Alignment.bottomCenter,
child: Container(
margin: EdgeInsets.only(bottom: CommonConstants.BOTTOM_BAR_HEIGHT, top: MediaQuery.of(context).size.height/2, left: 0, right: 0),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
border: Border.all(width: 0.5,color: ColorConstants.blackShade3),
),
child: <Your child widgets>,
),
);
},
transitionBuilder: (dialogContext, anim1, anim2, child) {
return SlideTransition(
position: Tween(begin: Offset(0, 1), end: Offset(0, 0)).animate(anim1),
child: child,
);
},
);