Skip to content

Commit 22f74ff

Browse files
authored
Merge pull request #19 from dungngminh/enhancement/scrollphysics-can-be-modified
enhancement: `ScrollPhysics` can be modified
2 parents d6b3d5d + 14dbb8f commit 22f74ff

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

lib/draggable_home.dart

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -75,40 +75,42 @@ class DraggableHome extends StatefulWidget {
7575
final Widget? bottomNavigationBar;
7676

7777
/// floatingActionButtonLocation: An object that defines a position for the FloatingActionButton based on the Scaffold's ScaffoldPrelayoutGeometry.
78-
7978
final FloatingActionButtonLocation? floatingActionButtonLocation;
8079

8180
/// floatingActionButtonAnimator: Provider of animations to move the FloatingActionButton between FloatingActionButtonLocations.
8281
final FloatingActionButtonAnimator? floatingActionButtonAnimator;
8382

83+
final ScrollPhysics? physics;
84+
8485
/// This will create DraggableHome.
85-
const DraggableHome({
86-
Key? key,
87-
this.leading,
88-
required this.title,
89-
this.centerTitle = true,
90-
this.actions,
91-
this.alwaysShowLeadingAndAction = false,
92-
this.alwaysShowTitle = false,
93-
this.headerExpandedHeight = 0.35,
94-
required this.headerWidget,
95-
this.headerBottomBar,
96-
this.backgroundColor,
97-
this.appBarColor,
98-
this.curvedBodyRadius = 20,
99-
required this.body,
100-
this.drawer,
101-
this.fullyStretchable = false,
102-
this.stretchTriggerOffset = 200,
103-
this.expandedBody,
104-
this.stretchMaxHeight = 0.9,
105-
this.bottomSheet,
106-
this.bottomNavigationBarHeight = kBottomNavigationBarHeight,
107-
this.bottomNavigationBar,
108-
this.floatingActionButton,
109-
this.floatingActionButtonLocation,
110-
this.floatingActionButtonAnimator,
111-
}) : assert(headerExpandedHeight > 0.0 &&
86+
const DraggableHome(
87+
{Key? key,
88+
this.leading,
89+
required this.title,
90+
this.centerTitle = true,
91+
this.actions,
92+
this.alwaysShowLeadingAndAction = false,
93+
this.alwaysShowTitle = false,
94+
this.headerExpandedHeight = 0.35,
95+
required this.headerWidget,
96+
this.headerBottomBar,
97+
this.backgroundColor,
98+
this.appBarColor,
99+
this.curvedBodyRadius = 20,
100+
required this.body,
101+
this.drawer,
102+
this.fullyStretchable = false,
103+
this.stretchTriggerOffset = 200,
104+
this.expandedBody,
105+
this.stretchMaxHeight = 0.9,
106+
this.bottomSheet,
107+
this.bottomNavigationBarHeight = kBottomNavigationBarHeight,
108+
this.bottomNavigationBar,
109+
this.floatingActionButton,
110+
this.floatingActionButtonLocation,
111+
this.floatingActionButtonAnimator,
112+
this.physics})
113+
: assert(headerExpandedHeight > 0.0 &&
112114
headerExpandedHeight < stretchMaxHeight),
113115
assert(
114116
(stretchMaxHeight > headerExpandedHeight) && (stretchMaxHeight < .95),
@@ -183,7 +185,7 @@ class _DraggableHomeState extends State<DraggableHome> {
183185
double topPadding,
184186
) {
185187
return CustomScrollView(
186-
physics: const BouncingScrollPhysics(),
188+
physics: widget.physics ?? const BouncingScrollPhysics(),
187189
slivers: [
188190
StreamBuilder<List<bool>>(
189191
stream: CombineLatestStream.list<bool>([

0 commit comments

Comments
 (0)