Skip to content

Instantly share code, notes, and snippets.

@januwA
Created November 18, 2019 12:35
Show Gist options
  • Save januwA/8bfdbcfe3436231c48f437a3e72729e6 to your computer and use it in GitHub Desktop.
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.
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