airy_bottom_sheet 1.2.0 airy_bottom_sheet: ^1.2.0 copied to clipboard
AiryBottomSheet is a very easy-to-use and stylish BottomSheet that seamlessly switches widgets by scrolling through the BottomSheet and adjusts like a magnet to the specified height when released.
AiryBottomSheet #
Thanks for looking!
WHAT'S THIS? #
AiryBottomSheet is a very easy-to-use and stylish BottomSheet that seamlessly switches widgets by scrolling through the BottomSheet and adjusts like a magnet to the specified height when released.
HOW TO USE (Only 3 steps!) #
1. Defines widgets wrapped in a Handle. #
The Handle widget is required to adjust the height of the AiryBottomSheet.
Widget _firstChild() {
return Column(
children: [
Handle(
controller: _controller,
child: Container(
color: Colors.redAccent,
height: 40,
),
),
Expanded(
child: Container(
color: Colors.black,
),
)
],
);
}
Widget _secondChild() {
return Handle(
controller: _controller,
child: Column(
children: [
Expanded(
child: Container(
color: Colors.red,
),
),
],
),
);
}
2. Prepare AiryBottomSheetController #
initialHeight
is the initial height of theAiryBottomSheet
.magnetPoints
is the height that is adjusted when the scroll is released.- -> why the type of
magnetPoints
isList<List<double>>
??- This is in contrast to
AiryBottomSheet.switchChildren
described below, which uses the information in the corresponding index to determine the widget and height to be displayed.
- This is in contrast to
- -> why the type of
maxHeight
is the maximum height of theAiryBottomSheet
.minHeight
is the minimum height of theAiryBottomSheet
.
final _controller = AiryBottomSheetController(
initialHeight: 100,
magnetPoints: [
[100],
[200, 300],
[400, 500],
],
maxHeight: 530,
minHeight: 80,
);
3. Call your AiryBottomSheet #
_scaffoldKey
isGlobalKey<ScaffoldState>
.controller
is prepared in Section 2.switchChildren
is paired withAiryBottomSheetController.magnetPoints
and the corresponding index height and widget will be displayed on theAiryBottomSheet
.onDragAndAnimationEnd
is literal. :)✨
AiryBottomSheet.show(
_scaffoldKey,
controller: _controller,
switchChildren: [
_firstChild(),
_secondChild(),
_thirdChild(),
],
onDragAndAnimationEnd: (height) {
debugPrint(height.toString());
},
);
Have a question? #
Write in issue!