Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello i am making app on flutter i need help in pageview builder whem your swipe left want jump pervious and when user swipe right i want user go to next page but for example user is 6 postion the click on swipe left it jum to postion 5 if it click on swipe right it jump 6 postion again i only want this using swipe in pageviewbuilder i have gridview in pervious sacreen when user select any item from gridview it navigate to Singleimage sacreen here is code of that sacreen so example if user clicked the item 6 from gridview it go to singlimage sacreen now when user swipe i want it postion jump to 5 or if it swipe right it postion must 7



Java
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

class Singleimage extends StatefulWidget {
  late final String foldername;
   late final int categorynumber;
  late final int index;
  late final String categoryname;

  Singleimage(this.foldername, this.categorynumber, this.index, this.categoryname);

  @override
  _SingleimageState createState() => _SingleimageState();
}

class _SingleimageState extends State<singleimage> {
  PageController controller = PageController();

  Duration pageTurnDuration = Duration(milliseconds: 500);
  Curve pageTurnCurve = Curves.ease;
  @override
  void initState() {
    super.initState();

  }



    @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title:Text('Name'),
      ),
      body: PageView.builder(
        onPageChanged: (int page) {
          // this page variable is the new page and will change before the pageController fully reaches the full, rounded int value
    
        },

        itemBuilder: (context, position) {
          return Container(
            child: Text('${position}',style: TextStyle(
              fontSize: 20
            ),),
            color: Colors.red,
          );
        },
        itemCount: 10,
      )
    );
  }
}


What I have tried:

i tried many time no solution found on any website
Posted
Updated 31-Jul-21 21:21pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900