Flutter ScrollController finout最大偏移量

时间:2019-05-16 10:37:57

标签: dart flutter

我想为CustomScrollView做一些自定义滚动进度指示器。

public static void main(String[] args) {

    //Scanner
    Scanner read = new Scanner(System.in);

    //Array of payRate Default
    double[] payRateDefault = {3.50, 4.00, 4.50, 4.75, 5.00, 5.25, 5.50, 5.75, 6.00};

    double payRateEntered;
    boolean isPayRate = false;

    char anotherProcess;

    System.out.print("Enter hours work: ");
    int hoursWork = read.nextInt();

    do {
        System.out.print("Enter pay rate: ");
        payRateEntered = read.nextDouble();

        for (int i = 0; i < payRateDefault.length; i++) {

            if (payRateDefault[i] == payRateEntered) {

                //If the payRate is true with array payRateDefault, proceed to ask if you have another employee
                System.out.println("Do you have any employee to process (Y/N)");
                anotherProcess = read.next().charAt(0);
                isPayRate = true;

                //Check if Y or N
                switch (anotherProcess) {
                    case 'Y':
                        //Proceed back to prompt user to enter pay rate

                        break;
                    case 'N':
                        //Proceed to calculation

                        break;
                    default:
                        //If wrong input
                        System.out.println("Please use Y or N only");
                        break;
                }
            } else {
                isPayRate = false;
            }
        }
        System.out.println("You have entered the wrong pay rate. Please try again");
    } while (!isPayRate);
}

有没有办法找出_scrollController最大偏移量?

或者我可以从Scrollbar小部件中获得一些价值吗?

1 个答案:

答案 0 :(得分:1)

所以您所需要的只是

scrollController.position.maxScrollExtent

这为您提供ListView

的最大滚动范围