8000 PageView's nextPage with Curves.elasticInOut doesn't navigate to the next page · Issue #160880 · flutter/flutter · GitHub
[go: up one dir, main page]

Skip to content
PageView's nextPage with Curves.elasticInOut doesn't navigate to the next page #160880
Open
@yesilcimenahmet

Description

@yesilcimenahmet

I'm encountering an issue with the PageView widget in Flutter. When using pageController.nextPage with the Curves.elasticInOut curve, the page animates as expected (with the elastic effect), but it doesn't actually navigate to the next page. It stays on the current page. Other curves, like Curves.easeInOut, work correctly.

Steps to reproduce

  1. Create a PageView with a PageController.
  2. Set physics to NeverScrollableScrollPhysics to disable manual scrolling.
  3. Implement a button or other interaction that calls pageController.nextPage with duration and Curves.elasticInOut.
  4. Observe that the page animates elastically but does not transition to the next page.
  5. Change the curve to Curves.easeInOut and observe the page transitions as expected.

Expected results

The PageView should smoothly transition to the next page with the elastic in-out animation provided by Curves.elasticInOut.

Actual results

The PageView performs the elastic animation but remains on the current page. It does not navigate to the next page.

Code sample

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('PageView Bug')),
        body: const MyHomePage(),
      ),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final PageController _pageController = PageController();

  void _nextPage() {
    _pageController.nextPage(
      duration: const Duration(milliseconds: 500),
      curve: Curves.elasticInOut, // This causes the issue
    );
        //_pageController.nextPage(
        //duration: const Duration(milliseconds: 500),
        //curve: Curves.easeInOut, // This works correctly
      //);
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Expanded(
          child: PageView(
            controller: _pageController,
            physics: const NeverScrollableScrollPhysics(),
            children: [
              Container(color: Colors.red),
              Container(color: Colors.blue),
            ],
          ),
        ),
        ElevatedButton(
          onPressed: _nextPage,
          child: const Text('Next Page (elasticInOut)'),
        ),
      ],
    );
  }
}

Screenshots or Video

No response

Logs

No response

Flutter Doctor output

[√] Flutter (Channel stable, 3.27.1, on Microsoft Windows [Version 10.0.26100.2605], locale tr-TR)
    • Flutter version 3.27.1 on channel stable at D:\fluttersdk\flutter
    • Upstream repository https://github.com/flutter/flutter.gitFramework revision 17025dd882 (10 days ago), 2024-12-17 03:23:09 +0900Engine revision cb4b5fff73
    • Dart version 3.6.0DevTools version 2.40.2

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at C:\Users\user\AppData\Local\Android\sdk
    • Platform android-35, build-tools 35.0.0Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.12.3)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\CommunityVisual Studio Community 2022 version 17.12.35527.113Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2024.2)
    • Android Studio at C:\Program Files\Android\Android StudioFlutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutterDart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dartJava version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)

[√] VS Code (version 1.96.2)
    • VS Code at C:\Users\user\AppData\Local\Programs\Microsoft VS CodeFlutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (4 available)
    • SM G998B (mobile) • emulator-5554 • android-x64    • Android 9 (API 28)
    • Windows (desktop) • windows       • windows-x64    • Microsoft Windows [Version 10.0.26100.2605]
    • Chrome (web)      • chrome        • web-javascript • Google Chrome 131.0.6778.205Edge (web)        • edge          • web-javascript • Microsoft Edge 131.0.2903.112

[√] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listf: gesturesflutter/packages/flutter/gestures repository.f: material designflutter/packages/flutter/material repository.found in release: 3.27Found to occur in 3.27found in release: 3.28Found to occur in 3.28frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0