Open
Description
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
- Create a PageView with a PageController.
- Set physics to NeverScrollableScrollPhysics to disable manual scrolling.
- Implement a button or other interaction that calls pageController.nextPage with duration and Curves.elasticInOut.
- Observe that the page animates elastically but does not transition to the next page.
- 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.git
• Framework revision 17025dd882 (10 days ago), 2024-12-17 03:23:09 +0900
• Engine revision cb4b5fff73
• Dart version 3.6.0
• DevTools 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.0
• Java 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\Community
• Visual Studio Community 2022 version 17.12.35527.113
• Windows 10 SDK version 10.0.22621.0
[√] Android Studio (version 2024.2)
• Android Studio at C:\Program Files\Android\Android Studio
• 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 21.0.3+-12282718-b509.11)
[√] VS Code (version 1.96.2)
• VS Code at C:\Users\user\AppData\Local\Programs\Microsoft VS Code
• Flutter 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.205
• Edge (web) • edge • web-javascript • Microsoft Edge 131.0.2903.112
[√] Network resources
• All expected network resources are available.
• No issues found!
Metadata
Metadata
Assignees
Labels
Important issues not at the top of the work listflutter/packages/flutter/gestures repository.flutter/packages/flutter/material repository.Found to occur in 3.27Found to occur in 3.28flutter/packages/flutter repository. See also f: labels.The issue has been confirmed reproducible and is ready to work onOwned by Framework teamTriaged by Framework team