Skip to content

Instantly share code, notes, and snippets.

@drexel-ue
Created July 6, 2020 01:25
Show Gist options
  • Save drexel-ue/64f9684b4ca9c0298c87f0e7bc40ec6a to your computer and use it in GitHub Desktop.
Save drexel-ue/64f9684b4ca9c0298c87f0e7bc40ec6a to your computer and use it in GitHub Desktop.
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