如何修复在Flutter中预期为标识符,但得到'“”

f8rj6qna  于 2023-01-21  发布在  Flutter
关注(0)|答案(1)|浏览(167)

flutter viewport的错误,当我尝试在Android上运行应用程序,甚至在Chrome上。我尝试了以下操作:

  • 重装Flutter
  • 创建新项目
  • 克隆现有项目
  • 在网络上运行更新android studio
  • 用户使用不同版本的Gradle
  • 升级java
  • flutter pub cache clean
  • 删除build文件夹

例外情况:

/flutter/packages/flutter/lib/src/rendering/viewport.dart:1375:15: Error: Expected an identifier, but got '.'.
Try inserting an identifier before '.'.
              .hasthrow FlutterError.fromParts(<DiagnosticsNode>[
              ^
/flutter/packages/flutter/lib/src/rendering/viewport.dart:1375:16: Error: Expected ';' after this.
              .hasthrow FlutterError.fromParts(<DiagnosticsNode>[
               ^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script '/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1156
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/Applications/Development/flutter/bin/flutter'' finished with non-zero exit value 1

房扑医生应要求:

[✓] Flutter (Channel stable, 3.0.5, on macOS 13.0 22A5311f darwin-x64, locale en-US)
    • Flutter version 3.0.5 at /Applications/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (3 weeks ago), 2022-07-13 
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2
⣯
Checking Android licenses is taking an unexpectedly long time...[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/alina/Library/Android/sdk
    • Platform android-31, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3
[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      :hammer: https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      :hammer: https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
[✓] VS Code (version 1.69.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.46.0
[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 13.0 22A5311f darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 103.0.5060.134
[✓] HTTP Host Availability
    • All required HTTP hosts are available
• No issues found!

[✓] Flutter (Channel stable, 3.0.5, on macOS 13.0 22A5311f darwin-x64, locale en-US)
    • Flutter version 3.0.5 at /Applications/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (3 weeks ago), 2022-07-13 
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2
⣯
Checking Android licenses is taking an unexpectedly long time...[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/alina/Library/Android/sdk
    • Platform android-31, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3
[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      :hammer: https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      :hammer: https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
[✓] VS Code (version 1.69.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.46.0
[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 13.0 22A5311f darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 103.0.5060.134
[✓] HTTP Host Availability
    • All required HTTP hosts are available
• No issues found!
yzuktlbb

yzuktlbb1#

如果有人遇到这个问题,那是因为他们修改了viewport的代码
要更正它,请转到错误指示的位置,并检查那里是否没有任何更改,例如,我碰巧添加了一个,而没有意识到这一点。

if (!constraints.hasBoundedHeight) {
          ,throw FlutterError.fromParts(<DiagnosticsNode>[
            ErrorSummary('Vertical viewport was given unbounded height.'),
            ErrorDescription(
              'Viewports expand in the scrolling direction to fill their container. '
              'In this case, a vertical viewport was given an unlimited amount of '
              'vertical space in which to expand. This situation typically happens '
              'when a scrollable widget is nested inside another scrollable widget.',
            ),
            ErrorHint(
              'If this widget is always nested in a scrollable widget there '
              'is no need to use a viewport because there will always be enough '
              'vertical space for the children. In this case, consider using a '
              'Column or Wrap instead. Otherwise, consider using a '
              'CustomScrollView to concatenate arbitrary slivers into a '
              'single scrollable.',
            ),
          ]);
        }

你能注意到我把逗号放在第二行代码的什么地方吗

相关问题