Created
November 18, 2019 12:35
-
-
Save januwA/8bfdbcfe3436231c48f437a3e72729e6 to your computer and use it in GitHub Desktop.
PageController's viewportFraction property is set to less than 1, and there is a bounce when switching pages.
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
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp(home: HomePage()); | |
} | |
} | |
class HomePage extends StatefulWidget { | |
@override | |
_HomePageState createState() => _HomePageState(); | |
} | |
class _HomePageState extends State<HomePage> { | |
PageController controller = PageController(viewportFraction: 0.8); | |
@override | |
Widget build(BuildContext context) { | |
var colors = [Colors.green, Colors.orange, Colors.purple]; | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('Home Page'), | |
), | |
body: Center( | |
child: PageView( | |
controller: controller, | |
children: <Widget>[ | |
for (var color in colors) | |
Container( | |
color: color, | |
) | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment