Skip to content
A flutter widget that slides through pages horizontally
Branch: master
Clone or download
Latest commit fab2239 Jun 5, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example Remove example app tests Jun 5, 2019
lib Add onFinished callback Jun 5, 2019
test Initial commit Jun 4, 2019
.gitignore Initial commit Jun 4, 2019
.metadata Initial commit Jun 4, 2019
CHANGELOG.md Add onFinished callback Jun 5, 2019
LICENSE Initial commit Jun 4, 2019
README.md
pubspec.lock Add onFinished callback Jun 5, 2019
pubspec.yaml Add onFinished callback Jun 5, 2019

README.md

flutter_page_slider

Pub

A simple Flutter widget that slides through pages horizontally. Use-cases could be wizards or onboarding flows similar to the Material Stepper widget, but without a particular UI - any widget can be a page to slide through.

Here's a demo of the example app:

PageSlider demo app

How to use

First, create the PageSlider widget with a GlobalKey<PageSliderState> and the child widgets which you want to slide through. Then, control the active page using the global key to address the page slider state like so:

class Demo extends StatefulWidget {
  Demo({Key key}) : super(key: key);
  _DemoState createState() => _DemoState();
}

class _DemoState extends State<Demo> {
  GlobalKey<PageSliderState> _sliderKey = GlobalKey();

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        PageSlider(
          key: _sliderKey,
          pages: [
            Text('Page 0'),
            Text('Page 1'),
            Text('Page 2'),
          ]
        ),
        RaisedButton(
          onPressed: _sliderKey.currentState.next,
          child: Text('Next')
        ),
        RaisedButton(
          onPressed: _sliderKey.currentState.previous,
          child: Text('Previous')
        ),
      ]
    );
  }
}
You can’t perform that action at this time.