Created
July 6, 2020 01:25
-
-
Save drexel-ue/64f9684b4ca9c0298c87f0e7bc40ec6a 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