Comments (2)
Relatedly, why is PageController.page
nullable when it throws if the page isn't available? It feels like an API should either return null if a valid value isn't available or throw-not both?
from flutter.
Reproducible using the code sample provided above.
complete sample
import '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
[!] Flutter (Channel stable, 3.19.6, on macOS 14.4.1 23E224 darwin-arm64, locale en-GB)
• Flutter version 3.19.6 on channel stable at /Users/nexus/dev/sdks/flutter
! Warning: `flutter` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
! Warning: `dart` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 54e66469a9 (17 hours ago), 2024-04-17 13:08:03 -0700
• Engine revision c4cd48e186
• Dart version 3.3.4
• DevTools version 2.31.1
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/nexus/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
• Xcode at /Applications/Xcode-15.3.0.app/Contents/Developer
• Build 15E204a
• CocoaPods version 1.14.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2023.1)
• Android Studio at /Users/nexus/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 17.0.7+0-17.0.7b1000.6-10550314)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
• IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
• Flutter plugin version 77.2.2
• Dart plugin version 232.10286
[✓] VS Code (version 1.88.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.86.0
[✓] Connected device (4 available)
• Nexus (mobile) • 00008020-001875E83A38002E • ios • iOS 17.4.1 21E236
• Dean’s iPad (mobile) • 00008103-000825C811E3401E • ios • iOS 17.4.1 21E236
• macOS (desktop) • macos • darwin-arm64 • macOS 14.4.1 23E224 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.60
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 1 category.
[✓] Flutter (Channel master, 3.22.0-13.0.pre.38, on macOS 14.4.1 23E224 darwin-arm64, locale en-GB)
• Flutter version 3.22.0-13.0.pre.38 on channel master at /Users/nexus/dev/sdks/flutters
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 86135b7774 (10 hours ago), 2024-04-17 20:08:36 -0700
• Engine revision 20638b75c8
• Dart version 3.5.0 (build 3.5.0-71.0.dev)
• DevTools version 2.35.0-dev.8
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/nexus/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
• Xcode at /Applications/Xcode-15.3.0.app/Contents/Developer
• Build 15E204a
• CocoaPods version 1.14.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2023.1)
• Android Studio at /Users/nexus/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 17.0.7+0-17.0.7b1000.6-10550314)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
• IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
• Flutter plugin version 77.2.2
• Dart plugin version 232.10286
[✓] VS Code (version 1.88.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.86.0
[✓] Connected device (5 available)
• Nexus (mobile) • 00008020-001875E83A38002E • ios • iOS 17.4.1 21E236
• Dean’s iPad (mobile) • 00008103-000825C811E3401E • ios • iOS 17.4.1 21E236
• macOS (desktop) • macos • darwin-arm64 • macOS 14.4.1 23E224 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.4.1 23E224 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.60
[✓] Network resources
• All expected network resources are available.
• No issues found!
from flutter.
Related Issues (20)
- mac-25 lost external connection phone device. HOT 1
- linux-45 is dead. HOT 2
- [flutter_markdown] Cannot Copy & Paste content inside markdown #105557 HOT 3
- Updating DefaultTabController with length greater than 2 in a StatefulWidget, then tapping the last tab, results in "setState() called after dispose()" exception HOT 2
- Add SecondaryTap callback to DataTable HOT 1
- Breakpoints skipped in unit tests when awaiting certain async calls HOT 2
- Execution failed for task ':gradle:compileGroovy' HOT 1
- linux-18 lost external connection phone device. HOT 1
- mac-24 lost external connection phone device. HOT 1
- [Impeller] slow frame in new gallery while navigating to travel application HOT 1
- Proposal: use "enhanced enums" in the repo for reduced boilerplate HOT 3
- mac-3 lost external connection phone device. HOT 1
- Add getter for floatingActionButtonLocation in ScaffoldState
- "One or more plugins require a higher Android SDK/NDK version" – tell me what these plugins are HOT 2
- [Impeller] Rendering difference using ImageFilter.matrix HOT 2
- mac-29 lost external connection phone device. HOT 1
- Directly access and communicate with printers on the Windows HOT 1
- Image picker: USB android debugging lost connection to device after taking picture using camera HOT 1
- [tool_crash] ShaderCompilerException HOT 1
- Card page doc have redundent prats HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter.