在 material_with_modal_page 中 Flutter 运行与 Flutter 版本相关的错误

标签 flutter flutter-dependencies

运行我的应用程序时出现此错误。

    Launching lib/main.dart on DAEGIL의 iPhone in debug mode...
    Automatically signing iOS for device deployment using specified development team in Xcode project: T6ULPGT4J7
    Xcode build done.                                           20.2s
    Failed to build iOS app
    Error output from Xcode build:
    ↳
        ** BUILD FAILED **
    Xcode's output:
    ↳
        ../../.pub-cache/hosted/pub.dartlang.org/modal_bottom_sheet-0.2.2/lib/src/material_with_modal_page_route.dart:21:16: Error: Getter not found: 'opaque'.
                assert(opaque),
                       ^^^^^^
        ../../.pub-cache/hosted/pub.dartlang.org/modal_bottom_sheet-0.2.2/lib/src/bottom_sheets/cupertino_bottom_sheet.dart:344:46: Error: No named parameter with the name 'shadowThemeOnly'.
            final isCupertinoApp = Theme.of(context, shadowThemeOnly: true) == null;
                                                     ^^^^^^^^^^^^^^^
        ../../fvm/versions/2.0.0/packages/flutter/lib/src/material/theme.dart:107:20: Context: Found this candidate, but the arguments don't match.
          static ThemeData of(BuildContext context) {
                           ^^
        ../../.pub-cache/hosted/pub.dartlang.org/modal_bottom_sheet-0.2.2/lib/src/bottom_sheets/material_bottom_sheet.dart:42:32: Error: No named parameter with the name 'shadowThemeOnly'.
              theme: Theme.of(context, shadowThemeOnly: true),
                                       ^^^^^^^^^^^^^^^
        ../../fvm/versions/2.0.0/packages/flutter/lib/src/material/theme.dart:107:20: Context: Found this candidate, but the arguments don't match.
          static ThemeData of(BuildContext context) {
                           ^^
        Command PhaseScriptExecution failed with a nonzero exit code
        note: Using new build system
        note: Building targets in parallel
        note: Planning build
        note: Constructing build description
    Could not build the precompiled application for the device.
    
    Error launching application on DAEGIL의 iPhone.
    Exited (sigterm)
Flutter 医生显示:


    [✓] Flutter (Channel stable, 2.0.1, on macOS 11.2.2 20D80 darwin-x64, locale en-CA)
        • Flutter version 2.0.1 at /Users/daegilpyo/Developer/flutter
        • Framework revision c5a4b4029c (3 days ago), 2021-03-04 09:47:48 -0800
        • Engine revision 40441def69
        • Dart version 2.12.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0-rc1)
        • Android SDK at /Users/daegilpyo/Library/Android/sdk
        • Platform android-30, build-tools 30.0.0-rc1
        • Java binary at: /Applications/12.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.3, Build version 12C33
        • CocoaPods version 1.10.0
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 3.6)
        • Android Studio at /Applications/12.app/Contents
        • Flutter plugin version 47.1.1
        • Dart plugin version 192.8052
        • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    
    [✓] Connected device (2 available)
        • DAEGIL의 iPhone (mobile) • 00008020-0011243A2279002E • ios            • iOS 14.4
        • Chrome (web)            • chrome                    • web-javascript • Google Chrome 88.0.4324.192
我不知道为什么会发生这个问题,这个错误与我的 flutter 版本有关吗?

最佳答案

据我所知,这是因为 modal_bottom_sheet包裹。
Flutter 中的一些更改使这个问题与空指针安全有关。它在版本 2.0.0-nullsafety.1 中得到修复.此版本引入了一些代码破坏性更改。

// Replace this 
showMaterialModalBottomSheet(
  context: context,
  builder: (context, scrollController) {
       return SingleChildScrollView(
        controller: scrollController,
        child: Container()
      )
  },
)

// With this 
showMaterialModalBottomSheet(
  context: context,
  builder: (context) {
      return SingleChildScrollView(
        controller: ModalScrollController.of(context),
        child: Container()
      )
  },
)
documentation 中进一步查看
更多信息请参见这些:
Opaque GitHub Issue
ShadowThemeOnly GitHub Issue

关于在 material_with_modal_page 中 Flutter 运行与 Flutter 版本相关的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66521630/

相关文章:

flutter - 如何在 Flutter 中将参数发送到 setstate

flutter - 在 Flutter 应用程序中从 pubspec for web 获取版本

android - 通过list <class>的实例达到特定功能

firebase - Firebase for Flutter 中此身份验证背后的逻辑是什么?

flutter - 有没有可以在 IOS 和 Android 设备上使用的 flutter-bluetooth-serial 包的替代方案?

firebase - Flutter:关于数据更改的 Firebase 推送通知

flutter : How to set fix width of Bar chart Column with scrolling x axis

flutter - SingleChildScrollView不可滚动

flutter - 如何在 flutter 中修复 'net::ERR_CLEARTEXT_NOT_PERMITTED'

flutter - 如何在flutter_svg中使用preCachePicture()