【错误记录】Flutter 组件报错 ( No Directionality widget found. | RichText widgets require a Directionality )
2023-06-13 09:17:49 时间
文章目录
一、报错信息
报错信息 :
Performing hot reload...
Syncing files to device Pixel 2...
Reloaded 0 libraries in 353ms.
======== Exception caught by widgets library =======================================================
The following assertion was thrown building Text("动画状态 : null"):
No Directionality widget found.
RichText widgets require a Directionality widget ancestor.
The specific widget that could not find a Directionality ancestor was: RichText
softWrap: wrapping at box width
maxLines: unlimited
text: "动画状态 : null"
dirty
The ownership chain for the affected widget is: "RichText ← Text ← Column ← Padding ← Container ← AnimationApp ← [root]"
Typically, the Directionality widget is introduced by the MaterialApp or WidgetsApp widget at the top of your application widget tree. It determines the ambient reading direction and is used, for example, to determine how to lay out text, how to interpret "start" and "end" values, and to resolve EdgeInsetsDirectional, AlignmentDirectional, and other *Directional objects.
The relevant error-causing widget was:
Text file:///D:/002_Project/002_Android_Learn/flutter_animation/lib/main.dart:118:11
When the exception was thrown, this was the stack:
#0 debugCheckHasDirectionality.<anonymous closure> (package:flutter/src/widgets/debug.dart:272:7)
#1 debugCheckHasDirectionality (package:flutter/src/widgets/debug.dart:292:4)
#2 RichText.createRenderObject (package:flutter/src/widgets/basic.dart:5539:37)
#3 RenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5423:28)
#4 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6166:11)
...
====================================================================================================
======== Exception caught by widgets library =======================================================
No Directionality widget found.
The relevant error-causing widget was:
Text file:///D:/002_Project/002_Android_Learn/flutter_animation/lib/main.dart:120:11
====================================================================================================
======== Exception caught by rendering library =====================================================
A RenderFlex overflowed by 199358 pixels on the bottom.
The relevant error-causing widget was:
Column file:///D:/002_Project/002_Android_Learn/flutter_animation/lib/main.dart:96:14
====================================================================================================
报错组件 :
Text("动画状态 : $animationStatus"),
Text("动画值 : $animationValue"),
二、解决方案
Flutter 中 Text 组件需要设置文本方向 ;
修改后的代码为 :
Text("动画状态 : $animationStatus", textDirection: TextDirection.ltr,),
Text("动画值 : $animationValue", textDirection: TextDirection.ltr,),
相关文章
- Python 有道翻译爬虫,破解 sign 参数加密反爬机制,解决{"errorCode":50}错误
- 关于socket通信bind()返回值错误:10049
- Flutter 下载器 | flutter_download_manager源码解析
- Windows Server 2008 R2x64 IIS7+PHP5.6 错误 500.0
- 【错误记录】Flutter 设备连接显示 Loading... ( 断网 | 删除 flutter/bin/cache/lockfile 文件 )
- 【错误记录】Flutter 环境安装相关问题 ( 执行 flutter doctor 命令后续错误处理 )
- 【错误记录】Flutter / Android 报错 ( AAPT: error: attribute android:requestLegacyExternalStorage not found )
- 【错误记录】Flutter 报错 ( Because xx depends on flutter_driver any from sdk which depends on args 1.6.0 )
- 【错误记录】Flutter 构建报错 ( Error: Method not found: ‘CupertinoModalPopupRoute‘. | 下载最新 Flutter SDK 版本 )
- 【错误记录】Flutter 界面报错 ( No MediaQuery widget ancestor found. | Scaffold widgets require a MediaQuery )
- 【错误记录】Flutter 界面跳转报错 ( Navigator operation requested with a context that does not include a Naviga )
- 【Flutter】Banner 轮播组件 ( flutter_swiper 插件 | Swiper 组件 )
- 【错误记录】Tinker 热修复示例运行报错 ( Execution failed for task ‘:app:tinkerProcessD‘ . tinkerId is not set!!! )
- 【错误记录】Android Studio 编译报错 ( cannot open this project, please retry with version 4.2 or newer. )
- 【错误记录】发布 Flutter 插件包报错 ( ‘gmail.com‘ has insufficient permissions to upload new versions of package)
- 【错误记录】Flutter 使用 MediaQuery 适配全面屏报错 ( No MediaQuery widget ancestor found. )
- 深入探讨 Linux 内部错误的原因及解决方案(linux内部错误)
- Oracle出现02068错误怎么办(oracle 02068)
- Oracle 00320错误解决方法一步步帮你排除故障(oracle 00320)
- Warning:session_destroy():Tryingtodestroyuninitializedsessionq错误
- jquery插件之信息弹出框showInfoDialog(成功/错误/警告/通知/背景遮罩)
- javascript代码运行不出来执行错误的可能情况整理
- Rails中遇到错误跳转到统一提示错误页的方法