Flutter报错:PageRoute<T>类未定义popDisposition getter
Flutter项目运行报错:The getter 'popDisposition' isn't defined for the class 'PageRoute'
项目此前运行数月正常,近期执行flutter run时控制台持续报错,提示The getter 'popDisposition' isn't defined for the class 'PageRoute<T>',报错指向stacked-3.4.4库,但我并未修改过pubspec.yaml文件。以下是项目配置和环境信息:
pubspec.yaml配置
name: enzo description: A new Flutter project. # The following line prevents the package from being accidentally published to # pub.dev using `flutter pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html version: 1.2.0+27 environment: sdk: ">=2.17.0 <3.0.0" dependencies: flutter: sdk: flutter qr_flutter: ^4.0.0 font_awesome_flutter: ^10.1.0 country_icons: ^2.0.2 smooth_page_indicator: ^1.0.0+2 shared_preferences: ^2.0.13 provider: ^6.0.3 flutter_svg: ^1.0.3 flutter_local_notifications: ^9.1.4 carousel_slider: ^4.1.1 dio: ^4.0.6 video_player: ^2.4.5 direct_link: ^0.1.9 flutter_spinkit: ^5.1.0 cupertino_icons: ^1.0.2 cached_network_image: ^3.2.3 json_annotation: ^4.9.0 google_maps_flutter: ^2.1.8 flutter_rating_bar: ^4.0.1 dropdown_button2: ^2.3.9 google_fonts: ^4.0.4 country_code_picker: ^3.0.0 visibility_detector: ^0.2.1 #loader_overlay: ^3.0.3 flutter_staggered_animations: ^1.0.0 webview_flutter: ^3.0.0 flutter_facebook_auth: ^3.5.7 google_sign_in: ^5.0.3 #firebase_auth: ^4.6.3 #firebase_core: ^2.14.0 #stacked_card_carousel: ^0.0.3-nullsafety.1 kkiapay_flutter_sdk: ^1.1.0 permission_handler: ^10.0.0 path_provider: ^2.0.11 image_picker: ^0.8.6 image_gallery_saver: ^1.7.1 responsive_sizer: ^3.1.1 share_plus: ^6.3.0 flutter_localizations: sdk: flutter intl: ^0.18.0 circle_flags: ^0.0.3 flutter_cached_pdfview: ^0.4.3 #loading_animation_widget: 1.2.0 #uiblock: 2.0.1 dev_dependencies: flutter_test: sdk: flutter build_runner: ^2.1.11 json_serializable: ^6.2.0 flutter_launcher_icons: ^0.9.2 flutter_app_name: ^0.1.0 # The "flutter_lints" package below contains a set of recommended lints to # encourage good coding practices. The lint set provided by the package is # activated in the `analysis_options.yaml` file located at the root of your # package. See that file for information about deactivating specific lint # rules and activating additional ones. flutter_lints: ^1.0.0 flutter_icons: android: true ios: true image_path: "assets/logos/logo1.png" remove_alpha_ios: true flutter_app_name: name: "MyCanalOlympia" # The following section is specific to Flutter. flutter: generate: true uses-material-design: true # To add assets to your application, add an assets section, like this: assets: - assets/ - assets/images/ - assets/docs/ - assets/docs/cgu.pdf - assets/icons/ - assets/logos/ - assets/board/ - assets/board/svg/ # fonts: # - family: Open Sans # fonts: # - asset: assets/fonts/opensansbold700.ttf # weight: 700 # - asset: assets/fonts/opensansopensans400.ttf # weight: 400 # - asset: assets/fonts/opensansopensansromanextrabold800.ttf # weight: 800 # - asset: assets/fonts/opensansopensansromansemibold600.ttf # weight: 600 # - asset: assets/fonts/opensanslight300.ttf # weight: 300 # - asset: assets/fonts/opensanssemibold600.ttf # weight: 600 # - family: Roboto # fonts: # - asset: assets/fonts/robotoregular400.ttf # weight: 400 flutter_intl: enabled: true analyzer: strong-mode: true language: enableSuperMixins: true
flutter doctor 结果
Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.13.6, on Microsoft Windows [version 10.0.19045.5247], locale fr-FR) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [√] Chrome - develop for the web [!] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.11.5) X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these components: MSVC v142 - VS 2019 C++ x64/x86 build tools - If there are multiple build tool versions available, install the latest C++ CMake tools for Windows Windows 10 SDK [√] Android Studio (version 2024.1) [√] VS Code (version 1.95.3) [√] Connected device (4 available) [√] Network resources
解决办法
- 问题原因:stacked-3.4.4依赖的
page_transition库使用了Flutter 3.x版本中已移除的popDisposition属性,而你当前Flutter版本为3.13.6,导致API不兼容。 - 修复步骤:
- 清理项目缓存:
flutter clean rm -rf pubspec.lock flutter pub get - 升级stacked库到兼容Flutter 3.13的版本,在pubspec.yaml中修改或添加:
# 若直接依赖stacked,修改版本: stacked: ^3.4.6 # 若为间接依赖,添加依赖覆盖: dependency_overrides: stacked: ^3.4.6 - 重新执行
flutter pub get后运行项目。 - 若仍报错,排查其他依赖库是否使用了过时的PageRoute相关API,同步升级对应库版本。
- 清理项目缓存:
内容的提问来源于stack exchange,提问作者Franck Dossou
相关产品推荐
相关产品推荐

