错误:在颤振中找不到类型“ui.TextHeightBehavior”

Posted

技术标签:

【中文标题】错误:在颤振中找不到类型“ui.TextHeightBehavior”【英文标题】:Error: Type 'ui.TextHeightBehavior' not found in flutter 【发布时间】:2020-05-19 06:27:22 【问题描述】:

我在终端命令中构建 appbundle 时遇到问题

编译器消息:

    ../../flutter/packages/flutter/lib/src/widgets/basic.dart:5149:9: Error: Type 'ui.TextHeightBehavior' not found.
      final ui.TextHeightBehavior textHeightBehavior;                       
            ^^^^^^^^^^^^^^^^^^^^^                                           
    ../../flutter/packages/flutter/lib/src/widgets/text.dart:149:9: Error: Type 'ui.TextHeightBehavior' not found.
      final ui.TextHeightBehavior textHeightBehavior;                       
            ^^^^^^^^^^^^^^^^^^^^^                                           
    ../../flutter/packages/flutter/lib/src/widgets/text.dart:432:9: Error: Type 'ui.TextHeightBehavior' not found.
      final ui.TextHeightBehavior textHeightBehavior;                       
            ^^^^^^^^^^^^^^^^^^^^^                                           
    ../../flutter/packages/flutter/lib/src/rendering/paragraph.dart:78:5: Error: Type 'ui.TextHeightBehavior' not found.
        ui.TextHeightBehavior textHeightBehavior,                           
        ^^^^^^^^^^^^^^^^^^^^^                                               
    ../../flutter/packages/flutter/lib/src/rendering/paragraph.dart:281:3: Error: Type 'ui.TextHeightBehavior' not found.
      ui.TextHeightBehavior get textHeightBehavior => _textPainter.textHeightBehavior;
      ^^^^^^^^^^^^^^^^^^^^^                                                 
    ../../flutter/packages/flutter/lib/src/rendering/paragraph.dart:282:26: Error: Type 'ui.TextHeightBehavior' not found.
      set textHeightBehavior(ui.TextHeightBehavior value)                  
                             ^^^^^^^^^^^^^^^^^^^^^                          
    ../../flutter/packages/flutter/lib/src/painting/text_painter.dart:145:5: Error: Type 'ui.TextHeightBehavior' not found.
        ui.TextHeightBehavior textHeightBehavior,                           
        ^^^^^^^^^^^^^^^^^^^^^                                               
    ../../flutter/packages/flutter/lib/src/painting/text_painter.dart:346:3: Error: Type 'ui.TextHeightBehavior' not found.
      ui.TextHeightBehavior get textHeightBehavior => _textHeightBehavior;  
      ^^^^^^^^^^^^^^^^^^^^^                                                 
    ../../flutter/packages/flutter/lib/src/painting/text_painter.dart:347:3: Error: Type 'ui.TextHeightBehavior' not found.
      ui.TextHeightBehavior _textHeightBehavior;                            
      ^^^^^^^^^^^^^^^^^^^^^                                                 
    ../../flutter/packages/flutter/lib/src/painting/text_painter.dart:348:26: Error: Type 'ui.TextHeightBehavior' not found.
      set textHeightBehavior(ui.TextHeightBehavior value)                  
                             ^^^^^^^^^^^^^^^^^^^^^                          
    ../../flutter/packages/flutter/lib/src/painting/text_style.dart:1070:5: Error: Type 'ui.TextHeightBehavior' not found.
        ui.TextHeightBehavior textHeightBehavior,                           
        ^^^^^^^^^^^^^^^^^^^^^                                               
    ../../flutter/packages/flutter/lib/src/widgets/basic.dart:5149:12: Error: 'TextHeightBehavior' isn't a type.
      final ui.TextHeightBehavior textHeightBehavior;                       
               ^^^^^^^^^^^^^^^^^^                                           
    ../../flutter/packages/flutter/lib/src/widgets/text.dart:149:12: Error: 'TextHeightBehavior' isn't a type.
      final ui.TextHeightBehavior textHeightBehavior;                       
               ^^^^^^^^^^^^^^^^^^                                           
    ../../flutter/packages/flutter/lib/src/widgets/text.dart:200:43: Error: 'TextHeightBehavior' isn't a type.
        properties.add(DiagnosticsProperty<ui.TextHeightBehavior>('textHeightBehavior', textHeightBehavior, defaultValue: null));
                                              ^^^^^^^^^^^^^^^^^^            
    ../../flutter/packages/flutter/lib/src/widgets/text.dart:432:12: Error: 'TextHeightBehavior' isn't a type.
      final ui.TextHeightBehavior textHeightBehavior;                       
               ^^^^^^^^^^^^^^^^^^                                           
    ../../flutter/packages/flutter/lib/src/widgets/text.dart:487:43: Error: 'TextHeightBehavior' isn't a type.
        properties.add(DiagnosticsProperty<ui.TextHeightBehavior>('textHeightBehavior', textHeightBehavior, defaultValue: null));
                                              ^^^^^^^^^^^^^^^^^^            
    ../../flutter/packages/flutter/lib/src/rendering/paragraph.dart:78:8: Error: 'TextHeightBehavior' isn't a type.
        ui.TextHeightBehavior textHeightBehavior,                           
           ^^^^^^^^^^^^^^^^^^                                               
    ../../flutter/packages/flutter/lib/src/rendering/paragraph.dart:282:29: Error: 'TextHeightBehavior' isn't a type.
      set textHeightBehavior(ui.TextHeightBehavior value)                  
                                ^^^^^^^^^^^^^^^^^^                          
    ../../flutter/packages/flutter/lib/src/painting/text_painter.dart:145:8: Error: 'TextHeightBehavior' isn't a type.
        ui.TextHeightBehavior textHeightBehavior,                           
           ^^^^^^^^^^^^^^^^^^                                               
    ../../flutter/packages/flutter/lib/src/painting/text_painter.dart:347:6: Error: 'TextHeightBehavior' isn't a type.
      ui.TextHeightBehavior _textHeightBehavior;                            
         ^^^^^^^^^^^^^^^^^^                                                 
    ../../flutter/packages/flutter/lib/src/painting/text_painter.dart:348:29: Error: 'TextHeightBehavior' isn't a type.
      set textHeightBehavior(ui.TextHeightBehavior value)                  
                                ^^^^^^^^^^^^^^^^^^                          
    ../../flutter/packages/flutter/lib/src/painting/text_painter.dart:422:7: Error: No named parameter with the name 'textHeightBehavior'.
          textHeightBehavior: _textHeightBehavior,                          
          ^^^^^^^^^^^^^^^^^^                                                
    org-dartlang-sdk:///flutter/lib/ui/text.dart:865:3: Context: Found this candidate, but the arguments don't match.
      ParagraphStyle(                                                      
      ^^^^^^^^^^^^^^                                                        
    ../../flutter/packages/flutter/lib/src/painting/text_style.dart:1070:8: Error: 'TextHeightBehavior' isn't a type.
        ui.TextHeightBehavior textHeightBehavior,                           
           ^^^^^^^^^^^^^^^^^^                                               
    ../../flutter/packages/flutter/lib/src/painting/text_style.dart:1091:7: Error: No named parameter with the name 'textHeightBehavior'.
          textHeightBehavior: textHeightBehavior,   

                        
      ^^^^^^^^^^^^^^^^^^                                                
org-dartlang-sdk:///flutter/lib/ui/text.dart:865:3: Context: Found this candidate, but the arguments don't match.
  ParagraphStyle(                                                      
  ^^^^^^^^^^^^^^                                                        
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.                                                           
                                                                        
FAILURE: Build failed with an exception.    

                        
                                                                    
哪里:脚本 '/Users/mac/Downloads/flutter/packages/flutter_tools/gradle/flutter.gradle' 线路:801
* What went wrong:                                                      
Execution failed for task ':app:compileFlutterBuildRelease'.            
> Process 'command '/Users/mac/Downloads/flutter/bin/flutter'' finished with non-zero exit value 1

**这是我的颤振医生:**

[✓] Flutter (Channel master, v1.14.7-pre.83, on Mac OS X 10.15.2 19C57,区域设置 en-ID) • Flutter 版本 1.14.7-pre.83,位于 /Users/mac/flutter • 框架修订e10df3c1a6(2天前),2020-02-01 11:23:01 +0800 • 引擎版本 e625e174c5 • Dart 版本 2.8.0(构建 2.8.0-dev.6.0 5ae5aff640)

[✓] android 工具链 - 为 Android 设备开发(Android SDK 版本 29.0.2) • Android SDK 位于 /Users/mac/Library/Android/sdk • 未配置 Android NDK 位置(可选;对原生分析支持有用) • 平台 android-29,构建工具 29.0.2 • Java 二进制文件位于:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java 版 OpenJDK 运行时环境(内部版本 1.8.0_202-release-1483-b49-5587405) • 接受所有 Android 许可证。

[✓] Xcode - 为 ios 和 macOS 开发 (Xcode 11.3.1) • Xcode 位于 /Applications/Xcode.app/Contents/Developer • Xcode 11.3.1,内部版本 11C504 • CocoaPods 1.8.4 版

[✓] Android Studio(版本 3.5) • Android Studio 位于 /Applications/Android Studio.app/Contents • Flutter 插件版本 43.0.1 • Dart 插件版本 191.8593 • Java 版 OpenJDK 运行时环境(内部版本 1.8.0_202-release-1483-b49-5587405)

[✓] IntelliJ IDEA 社区版(2018.2.2 版) • IntelliJ 位于 /Applications/IntelliJ IDEA CE.app • Flutter 插件版本 29.1.3 • Dart 插件版本 182.4129.13

之前我成功地将我的应用上传到 Google Playstore。但是当我想更新我的应用程序时,我遇到了这个问题。之前谢谢你

【问题讨论】:

能否请您显示您的代码而不是错误!!! 请考虑修改您在此问题中发布的代码示例。就目前而言,它的格式和范围使我们很难为您提供帮助;这是一个great resource,可以帮助您开始。 -1,不要走错路。否决票是我们在这里指出内容问题的方式;改进您的格式和代码示例,我(或有人会)很乐意将其还原。祝你的代码好运! 【参考方案1】:

改变你的颤振大师 在项目的终端写 颤振通道稳定

【讨论】:

【参考方案2】:

您好像在使用旧的 Flutter master 频道,修复升级到最新的 stable 频道

按照此命令切换频道:

flutter channel stable
flutter clean

然后运行

flutter upgrade       //to ensure you're on the latest.

【讨论】:

【参考方案3】:

在您应用的 pubspec.yaml 文件中查找以下行:flutter_widget_from_html 并使用版本 ^ 0.5.1 + 3

例如:flutter_widget_from_html: ^0.5.1+3

然后点击 pub upgrade 并运行您的应用

【讨论】:

以上是关于错误:在颤振中找不到类型“ui.TextHeightBehavior”的主要内容,如果未能解决你的问题,请参考以下文章

在你的颤振项目中找不到颤振 sdk 中的飞镖?

在我的颤振应用程序中找不到 proguard-rules.pro

在颤振医生中找不到Android SDK文件adb(命令提示符)

在 Android Studio 中找不到 Open for Editing

在颤动的根项目'audioplayer'中找不到任务'assembleAarRelease'

错误:在提供程序包中找不到类型“SingleChildCloneableWidget”