颤振升级后出现错误'textBaseline!= null'
Posted
技术标签:
【中文标题】颤振升级后出现错误\'textBaseline!= null\'【英文标题】:Error 'textBaseline != null' after flutter upgrade颤振升级后出现错误'textBaseline!= null' 【发布时间】:2020-07-22 13:35:14 【问题描述】:所以我在 master 上升级颤振后出现以下错误,为 web 构建。除了升级颤振我没有改变任何东西。切换分支和再次升级flutter似乎不起作用,以及flutter clean和pub upgrade/ packages get。
[+5273 ms] ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
[ +318 ms] The following assertion was thrown building InputDecorator(decoration: InputDecoration(hintMaxLines:
[ +104 ms] "1", floatingLabelBehavior: FloatingLabelBehavior.auto, focusedBorder: UnderlineInputBorder(),
[ +11 ms] disabledBorder: UnderlineInputBorder(), enabledBorder: UnderlineInputBorder(), alignLabelWithHint:
[ +1 ms] false), baseStyle: TextStyle(inherit: true, size: 15.0), isFocused: false, isEmpty: true, dirty,
[ +13 ms] dependencies: [_EffectiveTickerMode, _InheritedTheme, _LocalizationsScope-[GlobalKey#83362],
[ +3 ms] Directionality, MediaQuery], state: _InputDecoratorState#403a5(tickers: tracking 2 tickers)):
[ +2 ms] Assertion failed:
[ +10 ms] file:///C:/Users/me/Documents/flutter/packages/flutter/lib/src/material/input_decorator.dart:1664:15
[ +2 ms] textBaseline != null
[ +1 ms] is not true
[ +4 ms] The relevant error-causing widget was:
[ +10 ms] TextField
[ +1 ms] file:///C:/Users/me/Desktop/work/platform/lib/views/login/login_content.dart:195:28
[ +2 ms] When the exception was thrown, this was the stack:
[ +13 ms] C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 195:49 throw_
[ +16 ms] C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 26:3 assertFailed
[ +18 ms] packages/flutter/src/material/input_decorator.dart 1664:27 new
[ +3 ms] packages/flutter/src/material/input_decorator.dart 2312:12 build
[ +204 ms] packages/flutter/src/widgets/framework.dart 4623:28 build
[ +17 ms] packages/flutter/src/widgets/framework.dart 4506:15 performRebuild
[ +5 ms] packages/flutter/src/widgets/framework.dart 4679:11 performRebuild
[ +13 ms] packages/flutter/src/widgets/framework.dart 4222:5 rebuild
[...] (many more lines)
[ +11 ms] packages/flutter/src/widgets/binding.dart 921:24 attachRootWidget
[ +1 ms] packages/flutter/src/widgets/binding.dart 903:7 <fn>
[ +1 ms] C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/isolate_helper.dart 50:19 internalCallback
[ +3 ms] ════════════════════════════════════════════════════════════════════════════════════════════════════
该问题会影响应用程序中的每个文本字段。
颤振医生:
[√] Flutter (Channel master, v1.18.0-5.0.pre.54, on Microsoft Windows [Version 10.0.18363.720], locale de-DE)
• Flutter version 1.18.0-5.0.pre.54 at C:\Users\me\Documents\flutter
• Framework revision 292bbd872d (52 minutes ago), 2020-04-09 11:58:13 -0700
• Engine revision 5b4b1f33c6
• Dart version 2.8.0 (build 2.8.0-dev.20.0 dcdc71d763)
[√] android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at C:\Users\me\AppData\Local\Android\sdk
• Platform android-29, build-tools 29.0.2
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 3.6)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 44.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[!] IntelliJ IDEA Ultimate Edition (version 2019.1)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2019.1.2
X Flutter plugin not installed; this adds Flutter specific functionality.
• Dart plugin version 191.8593
• For information about installing plugins, see
https://flutter.dev/intellij-setup/#installing-the-plugins
[√] VS Code (version 1.44.0)
• VS Code at C:\Users\me\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.9.1
[√] Connected device (2 available)
• Chrome • chrome • web-javascript • Google Chrome 81.0.4044.92
• Web Server • web-server • web-javascript • Flutter Tools
! Doctor found issues in 1 category.
感谢您的帮助!
【问题讨论】:
【参考方案1】:将 textBaseline 添加到 TextField 的样式中。
style: TextStyle(textBaseline: TextBaseline.alphabetic)
【讨论】:
非常感谢,这拯救了我的项目。我还是不明白,为什么这突然变得相关了以上是关于颤振升级后出现错误'textBaseline!= null'的主要内容,如果未能解决你的问题,请参考以下文章
依赖项升级后 Android Firebase 依赖项出现颤振问题
错误:无法“发布升级”颤振工具。 5 秒后重试...(还剩 9 次尝试)
升级颤振后颤振标签栏错误“getter'key'被称为null”