-
-
Save slightfoot/2f561504d5ad451b8dede77357dccddf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Scrollable( | |
axisDirection: AxisDirection.right, | |
controller: _pageController, | |
physics: const PageScrollPhysics(parent: ClampingScrollPhysics()), | |
viewportBuilder: (BuildContext context, ViewportOffset offset) { | |
return LayoutBuilder( | |
builder: (context, constraints) { | |
offset.applyViewportDimension(constraints.maxWidth); | |
offset.applyContentDimensions(0.0, constraints.maxWidth); | |
return AnimatedBuilder( | |
animation: offset, | |
builder: (BuildContext context, Widget child) { | |
return Transform.translate( | |
offset: Offset(-offset.pixels, 0.0), | |
child: child, | |
); | |
}, | |
child: ChangeNotifierProvider<ViewportOffset>.value( | |
value: offset, | |
child: OverflowBox( | |
alignment: Alignment.topLeft, | |
minHeight: constraints.maxHeight, | |
maxHeight: constraints.maxHeight, | |
minWidth: constraints.maxWidth * 2, | |
maxWidth: constraints.maxWidth * 2, | |
child: Row( | |
crossAxisAlignment: CrossAxisAlignment.stretch, | |
children: [ | |
Expanded( | |
child: Page1(), | |
), | |
Expanded( | |
child: Page2(), | |
), | |
], | |
), | |
), | |
), | |
); | |
}, | |
); | |
}, | |
), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment