Skip to content

Instantly share code, notes, and snippets.

@Blasanka
Last active November 25, 2019 17:30
Show Gist options
  • Save Blasanka/a870803bb57bb57caf7eea11698e5a19 to your computer and use it in GitHub Desktop.
Save Blasanka/a870803bb57bb57caf7eea11698e5a19 to your computer and use it in GitHub Desktop.
This is a example source code for infinite pageview in flutter. Read the tutorial here: https://slcoderlk.blogspot.com/2018/05/motiv-quote-app-pageview-for-swipe.html
import 'package:flutter/material.dart';
void main() => runApp(LimeApp());
class LimeApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Lime',
theme: ThemeData(
canvasColor: Colors.primaries[6],
),
home: MainPage(),
);
}
}
class MainPage extends StatelessWidget {
List<Widget> pages = [YourPage(), YourSecondPage(), YourThirdPage()];
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
decoration: BoxDecoration(
color: Colors.black54,
),
margin: EdgeInsets.symmetric(
vertical: 50.0,
horizontal: 10.0,
),
child: PageView.builder(
controller: PageController(
initialPage: 1,
viewportFraction: 0.8,
),
itemBuilder: (_, int index) => pages[index];
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment