简体   繁体   中英

How to slide from pageview to other pages [Flutter]

I tried to slide from pageview to other pages I use the stack layout but I will get an Warning,Unable to slide pageview I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this. Wanted to know if it's good practice to do that and what would be the best way to do that? Thanks in advance.

Stack(
        children: <Widget>[
          Positioned(
            child: Container(
              color: Colors.deepOrange,
            ),
          ),
          Positioned(
            child: PageView(
              scrollDirection: Axis.horizontal,
              controller: _pageController,
              reverse: false,
              physics: PageScrollPhysics(parent: BouncingScrollPhysics()),
              onPageChanged: (pageIndex) {
                _pageIndex = pageIndex;
                // print(_pageController.page);
                // print(pageIndex);
                if (pageIndex == 2) {}
              },
              children: <Widget>[
                Container(
                  color: Colors.blue,
                ),
                Container(
                  color: Colors.pink,
                ),
                Container(
                  color: Colors.green,
                )
              ],
            ),
          ),
        ],
      ),

Do you have something like

PageController controller = PageController();

on you class that you are not showing?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM