No Directionality widget found
The problem is not that you have not wrapped your widgets into MaterialApp. As the documentation says this error occurs due to the nesting of the same kind of Widgets like nesting of Row into Row, Column into Column or Column into ListView so the problem arises as it becomes unbounded constraints for the Widget so unable to identify the direction.
So to avoid this kind of problems usage of Flexible or Expanded occurs which identifies the remaining space.
用 materialapp:
import 'package:flutter/material.dart';
import 'dart:ui' as ui;
void main() {
runApp(new MyApp());
} class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
return MaterialApp(
title: 'hello',
home: Container(
color: Colors.red,
child: Column(
children: <Widget>[
RaisedButton(
child: Text('just test', textDirection: TextDirection.ltr,),
)
],
),
),
);
}
}
不用materialapp
import 'package:flutter/material.dart';
import 'dart:ui' as ui;
void main() {
runApp(new MyApp());
} class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
return MediaQuery(
data: MediaQueryData.fromWindow(ui.window),
child: Directionality(textDirection: TextDirection.rtl, child: Container(
color: Colors.grey,
child: Column(
children: <Widget>[
RaisedButton(
child: Text('just test', textDirection: TextDirection.ltr,),
)
],
),
)),
);
}
}
No Directionality widget found的更多相关文章
- No Directionality widget found.错误记录。
import 'package:flutter/material.dart'; void main() => runApp(new Center(child: new Text('Hello, ...
- 【译】使用 Flutter 实现跨平台移动端开发
作者: Mike Bluestein | 原文地址:[https://www.smashingmagazine.com/2018/06/google-flutter-mobile-developm ...
- StructureMap 代码分析之Widget 之Registry 分析 (1)
说句实话,本人基本上没用过Structuremap,但是这次居然开始看源码了,不得不为自己点个赞.Structuremap有很多的类,其中有一个叫做Widget的概念.那么什么是Widget呢?要明白 ...
- Sencha ExtJS 6 Widget Grid 入门
最近由于业务需要,研究了一下Sencha ExtJS 6 ,虽然UI和性能上据相关资料说都有提升,但是用起来确实不太顺手,而且用Sencha cmd工具进行测试和发布,很多内部细节都是隐藏的,出了问题 ...
- 使用 CoordinatorLayout 出错 inflating class android.support.design.widget.CoordinatorLayout
ava.lang.RuntimeException: Unable to start activity ComponentInfo{com.czr.ianpu/com.czr.ianpu.MainAc ...
- yii2——自定义widget
参考资料:http://www.bsourcecode.com/yiiframework2/how-to-create-custom-widget-in-yii2-0-framework/ 如何使 ...
- Yii2 时间控件之把layDate做成widget
实现效果如下 1.把layDate封装成Yii2的widget,存在 "\common\widgets"目录下,命名为DycLayDate,具体引用查看代码. 2.对应的model ...
- 解决Android中No resource found that matches android:TextAppearance.Material.Widget.Button.Inverse问题
解决Android中No resource found that matches android:TextAppearance.Material.Widget.Button.Inverse问题http ...
- Ext.js细节:在MVC中处理Widget Column,GetCmp和ComponentQuery, Id和ItemId
针对EXT.JS版本的演进,要不断的学习新的最佳实践方法. 比如,在定义组件时,尽管用itemid,而不是id. 在搜索组件时,尽量用ComponentQuery,而不是getCmp. 在MVC中处理 ...
随机推荐
- CSS属性选择器和部分伪类
p[name]{background:red;} 只使用属性名p[name=ghr]{background:red;} 指定属性名,并指定了该属性的属性值p[name~=old]{background ...
- MSVCP110.DLL没有被指定在WINDOWS上运行
要重新安装C++ 运行库 为msvcp110.dll是VC++2012的文件 数字代表版本msvcp120是VC++2013的 110是2012的 100是2010的 90是2008的 71是2005 ...
- nginx 报错 connect() failed (111: Connection refused) while connecting to upstream
公司网站搬迁到新服务器后,发现站点访问不了,network里面提示502,查看相关的server配置,感觉没有什么问题,经过测试发现txt.html.等非php文件能够直接访问,也就是php访问不了, ...
- memoization提升递归效率
从开通博客到目前为止,也有一年了,刚开始的写了一篇工作的感想,然后就一直不知道写什么,看园子里的文章实在是很专业,怕自己写的太水.但是,写一些东西总归是好的,于是就当作是记笔记一样,开始写第一篇技术类 ...
- 22.1 、react生命周期(一)
在每个react组件中都有以下几个生命周期方法~我们需要在不同阶段进行讨论 组件生命周期概述 1.初始化 在组件初始化阶段会执行 constructor static getDerivedStateF ...
- socket与http
参考文档:http://blog.csdn.net/zeng622peng/article/details/5546384 1.TCP连接 手机能够使用联网功能是因为手机底层实现了TCP/IP协议,可 ...
- 【持续集成】GIT+jenkins+sonar——GIT
一.GIT基础 1.1 git简介 linus用C语言编写 2005年诞生 分布式管理系统 速度快.适合大规模.跨地区多人协同开发 1.2 本地管理.集中式.分布式 1.3 git安装 #CentOS ...
- 剑指offer——python【第15题】反转链表
题目描述 翻转一个链表 样例:给出一个链表1->2->3->null,这个翻转后的链表为3->2->1->null 思路 一种比较简单的方法是用“摘除法”.就是先新 ...
- ubuntu14.04 LTS 更新国内网易163源
2015/10/7 更改ubuntu的默认源是linux学习中必须掌握的基础技能.在此记录,以作参考. 在ubuntu14.04 LTS默认使用的是国外源,由于网络的原因,使用apt-get安装包时异 ...
- 浅谈Vue 项目性能优化 经验
我优化公司的项目总结的几点: 1.先查看引入的图片大小,如果太大了,可以压缩,压缩路径:https://zhitu.isux.us/ 2.代码包优化, 待下项目开发完成.进行打包源码上线环节,需要对项 ...