Skip to content

PageView seems to ignore PageController's page after state changes #106708

@jfahrenkrug

Description

@jfahrenkrug

Steps to Reproduce

  1. Pull down the pagecontroller_problem_demo branch from https://github.com/thesmythgroup/easy_image_viewer/tree/pagecontroller_problem_demo
  2. Run the example app (example/lib/main.dart) in an iOS simulator
  3. Tap on Show Multiple Images (Simple).
  4. Swipe to the second image
  5. Use pinch & zoom to zoom in.

Expected results:
The PageView stays on the 2nd image

Actual results:
The PageView jumps back to the first image.

Background

I'm having the following problem: My library easy_image_viewer has a request to add swipe-to-dismiss. I implemented it using the Dismissible widget. However, when the user zooms in on an image, I noticed I had to find a way to "deactivate" the Dismissible widget because otherwise the user can't pan around on the zoomed-in image. I solved that by using setState and a dismissDirection variable on the state that can be either none or down. Now for the weird part: Whenever I call setState and the dismissDirection changes, the PageView jumps back to the first item. I've tried using AutomaticKeepAliveClientMixin, but to no avail. I'm probably doing something wrong, but I can't figure out what it is.

Logs
[✓] Flutter (Channel stable, 3.0.2, on macOS 12.4 21F79 darwin-arm, locale en-US)
    • Flutter version 3.0.2 at /Users/johannes/Code/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision cd41fdd495 (3 weeks ago), 2022-06-08 09:52:13 -0700
    • Engine revision f15f824b57
    • Dart version 2.17.3
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/johannes/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

[✓] VS Code (version 1.68.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.42.0

[✓] Connected device (4 available)
    • sdk gphone64 arm64 (mobile)    • emulator-5554                        • android-arm64  • Android 12 (API 32) (emulator)
    • iPad (9th generation) (mobile) • 6EEE8A28-98D4-45D9-BB99-2E7AE15EADC2 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-5 (simulator)
    • macOS (desktop)                • macos                                • darwin-arm64   • macOS 12.4 21F79 darwin-arm
    • Chrome (web)                   • chrome                               • web-javascript • Google Chrome 103.0.5060.53
    ! Error: Johannes' iPad Air is not connected. Xcode will continue when Johannes' iPad Air is connected. (code -13)

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Movie:

flutter-pageview-demo.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    r: invalidIssue is closed as not valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions