flutter - 是否可以在 Flutter 中使用没有 MaterialApp 的 GridView?
问题描述
我是 Flutter 的新手,我正在为一些概念而苦苦挣扎。
我无法在这样的容器内使用 GridView() 小部件:
class _ProductsGridState extends State<ProductsGrid> {
@override
Widget build(BuildContext context) {
return Container(
child: GridView.count(
crossAxisCount: 2,
),
);
}
}
调试控制台给了我这个错误:
包:flutter/src/painting/basic_types.dart':断言失败:第 225 行 pos 10:'textDirection != null':不正确
谢谢 !:)
解决方案
MaterialApp 是您的应用程序的根级小部件,它在幕后做了很多工作,为您提供一个基本页面,您可以在其中添加多个小部件,这些小部件可以在屏幕上显示。没有 Materialapp,您的应用程序将无法正常工作。
推荐阅读
- asp.net-web-api - ASP.NET Web API:请求的资源上不存在“Access-Control-Allow-Origin”标头
- python - 如何从 C++ 中的 pandas Timestamp 对象中提取年/小时/日数据?
- reactjs - 使用 GatsbyJS 和 Material-UI 重新加载页面时样式消失
- flutter - Flutter:在 null 上调用了方法“[]”
- c# - 如何使用 C# 中的 ValueType 参数调用 C++/Cli 函数
- javascript - 如何在javascript中将html代码转换为char?
- reactjs - 使用 useRef 或 createRef 而不是 inline ref 有什么优势?
- office-js - 从标准浏览器打开页面
- swift - Throttle 发布者如何在 Swift Combine 中工作?
- python - Django 投票系统:以适当的方式确定排名