-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't access PageController.page
even when hasClients
is true
#146986
Labels
f: scrolling
Viewports, list views, slivers, etc.
found in release: 3.19
Found to occur in 3.19
found in release: 3.22
Found to occur in 3.22
framework
flutter/packages/flutter repository. See also f: labels.
has reproducible steps
The issue has been confirmed reproducible and is ready to work on
P2
Important issues not at the top of the work list
team-framework
Owned by Framework team
triaged-framework
Triaged by Framework team
Comments
Relatedly, why is |
danagbemava-nc
added
in triage
Presently being triaged by the triage team
framework
flutter/packages/flutter repository. See also f: labels.
has reproducible steps
The issue has been confirmed reproducible and is ready to work on
team-framework
Owned by Framework team
found in release: 3.19
Found to occur in 3.19
found in release: 3.22
Found to occur in 3.22
and removed
in triage
Presently being triaged by the triage team
labels
Apr 18, 2024
Reproducible using the code sample provided above. complete sampleimport 'package:flutter/material.dart';
void main() async {
runApp(const PageDemo());
}
class PageDemo extends StatefulWidget {
const PageDemo({super.key});
@override
State<PageDemo> createState() => _PageDemoState();
}
class _PageDemoState extends State<PageDemo> {
final PageController controller = PageController();
@override
Widget build(BuildContext context) {
if (controller.hasClients) {
print(controller.page);
}
return MaterialApp(
home: Scaffold(
body: PageView(
controller: controller,
children: [
// Only throws if a builder or sub widget is used here.
Builder(
builder: (context) {
final double currentPage =
controller.hasClients ? controller.page ?? -1 : -2;
return Center(child: Text(currentPage.toString()));
},
),
],
),
),
);
}
} flutter doctor -v
|
goderbauer
added
f: scrolling
Viewports, list views, slivers, etc.
P2
Important issues not at the top of the work list
triaged-framework
Triaged by Framework team
labels
Apr 23, 2024
9 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
f: scrolling
Viewports, list views, slivers, etc.
found in release: 3.19
Found to occur in 3.19
found in release: 3.22
Found to occur in 3.22
framework
flutter/packages/flutter repository. See also f: labels.
has reproducible steps
The issue has been confirmed reproducible and is ready to work on
P2
Important issues not at the top of the work list
team-framework
Owned by Framework team
triaged-framework
Triaged by Framework team
Steps to reproduce
pages
PageController.page
from inside the builder/subwidget, checkingcontroller.hasClients
firstExpected results
The current page is displayed or a fallback if no page is available (has client is false or the page is null)
Actual results
Page value is only available after content dimensions are established.
is thrown and the screen flashes red before properly displaying the page number.Code sample
Code sample
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]
Flutter Doctor output
Doctor output
[Paste your output here]
The text was updated successfully, but these errors were encountered: