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中处理 ...
随机推荐
- Code::Blocks设置支持C++ 11
进入codeblocks,点击Settings --> Compiler..,进入如下页面 勾选“Have g++ follow the C++11 ISO language standard ...
- 解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误
我调这个bug调了一天多,在网上搜索的检查namespace,package等,都没有错.错误提示是没有找到xml文件,我就纳闷了,为什么找不到呢?后来才发现,原来是resource中奇怪的目录为题, ...
- [LeetCode] Wiggle Sort II 摆动排序之二
Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]... ...
- 算法提高 最小方差生成树(Kruskal)_模板
算法提高 最小方差生成树 时间限制:1.0s 内存限制:256.0MB 问题描述 给定带权无向图,求出一颗方差最小的生成树. 输入格式 输入多组测试数据.第一行为N,M,依次是 ...
- git 处理
[添加]cd 路径(进入文件夹) git clone url git status (查看状态) cd firstprojected 进入这个文件夹 查看 git status 有 index.php ...
- Javascript中只能在 HTML 输出流中使用 document.write,在文档已加载后使用它(比如在函数中),会覆盖整个文档。
意思就是说,初次加载时如果没有加载document.write,那么再次加载的时候回覆盖掉原来的内容,只显示新加载的内容. <!DOCTYPE html> <html> < ...
- Hadoop fs -put bandwidth 暴力版
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreem ...
- Changing Ethernet Media Speed for AIX
ITS UNIX Systems Changing Ethernet Media Speed for AIX First you need to find out the device name of ...
- jquery异步ajax超大长度base64图片长字段数据传输问题解决办法和php后台处理办法
2017年5月9日19:25:02 在做在线签名的时候,到了图片上传的时候,使用jquery异步ajax上传base64的图片数据的时候,使用默认的方式进行数据传输偶尔会出现 生产的图片只有上半部分, ...
- Parallel.ForEach 多线程 声明失败 "未将对象引用设置到对象的实例"
x using System; using System.Collections.Generic; namespace Parallel.ForEach { class Program { //代码结 ...