Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I use Parallax transformer in basic PageView.builder? #10

Open
NTMS2017 opened this issue May 27, 2019 · 0 comments
Open

How can I use Parallax transformer in basic PageView.builder? #10

NTMS2017 opened this issue May 27, 2019 · 0 comments

Comments

@NTMS2017
Copy link

I have a basic page view with 3 pges and I have my own content. How can I use Parallax transformer?

  final _controller = new PageController();
  final List<Widget> _pages = [
    Page1(),
    Page2(),
    Page3(),
  ];
  int page = 0;

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    bool isDone = page == _pages.length - 1;
    return new Scaffold(
        backgroundColor: Colors.transparent,
        drawer: new PrimeDrawer(index: page),
        body: new Stack(
          children: <Widget>[
            // FULL PAGE
            new Positioned.fill(
              child: new PageView.builder(
                physics: new AlwaysScrollableScrollPhysics(),
                controller: _controller,
                itemCount: _pages.length,
                itemBuilder: (BuildContext context, int index) {
                  return _pages[index % _pages.length];
                },
                onPageChanged: (int p) {
                  setState(() {
                    page = p;
                  });
                },
              ),
            ),

 //TOP BAR
            new Positioned(
              top: 0.0,
              left: 0.0,
              right: 0.0,
              child: new SafeArea(
                child: AppBar(
                  backgroundColor: Colors.transparent,
                  elevation: 0.0,
                  primary: false,
                  actions: <Widget>[
                    FlatButton(
                      child: Icon(
                        isDone ? Icons.home : Icons.arrow_forward_ios,
                        size: 20,
                        color: Colors.white,
                      ),
                      onPressed: isDone
                          ? () {
                              //Navigator.pop(context);
                              _controller.animateToPage(0,
                                  duration: Duration(milliseconds: 200),
                                  curve: Curves.easeOut);
                            }
                          : () {
                              _controller.animateToPage(page + 1,
                                  duration: Duration(milliseconds: 200),
                                  curve: Curves.easeIn);
                            },
                    )
                  ],
                ),
              ),
            ),

 new Positioned(
              bottom: 10.0,
              left: 0.0,
              right: 0.0,
              child: new SafeArea(
                child: new Column(
                  children: <Widget>[
                    new Padding(
                      padding: const EdgeInsets.all(8.0),
                      child: new DotsIndicator(
                        controller: _controller,
                        itemCount: _pages.length,
                        onPageSelected: (int page) {
                          _controller.animateToPage(
                            page,
                            duration: const Duration(milliseconds: 300),
                            curve: Curves.ease,
                          );
                        },
                      ),
                    ),
                  ],
                ),
              ),
            ),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant