gpt4 book ai didi

flutter - 什么时候 flex 类比列和行类更有利?

转载 作者:行者123 更新时间:2023-12-04 10:43:59 25 4
gpt4 key购买 nike

来自关于 flex class: 的文档

The Flex widget allows you to control the axis along which the children are placed (horizontal or vertical). This is referred to as the main axis. If you know the main axis in advance, then consider using a Row (if it's horizontal) or Column (if it's vertical) instead, because that will be less verbose.



该文档表明您不知道哪个方向是主轴(水平或垂直)。你怎么可能不知道主轴,你为什么要改变它?你会在某些情况下只在旋转屏幕的情况下使用 flex 吗?或者这只是一个过时的类(class)?

最佳答案

不,这不是过时的类(class)。当您使用 Row Column , 你知道方向但你可以使用 Flex并根据需要更改方向(旋转或其他方式,可能取决于条件)。

然而, Row Column继承自 Flex .如果您阅读了 Row class doc,您将看到如下内容:

Inheritance

 Object -> Diagnosticable -> DiagnosticableTree -> Widget -> RenderObjectWidget  -> MultiChildRenderObjectWidget -> Flex -> Row


Flexible 小部件还有一个名为 ParentDataWidget 的父类类型 Flex .

关于flutter - 什么时候 flex 类比列和行类更有利?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59796442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com