颤振:未显示VerticalDivider

时间:2020-05-09 03:53:46

标签: flutter flutter-layout

我有这个小部件树:

Scaffold
  AppBar
  Column
    Center
    SingleChildScrollView
    FutureBuilder
       Container
       Flex
          direction: Axis.vertical,
          children: <Widget>[
              Row(
                          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                          children: <Widget>[
                            FlatButton(
                              color: Colors.red,
                              onPressed: () => {},
                              padding: EdgeInsets.all(10.0),
                              child: Row(
                                children: <Widget>[
                                  Icon(
                                    Icons.star,
                                    color: Colors.red,
                                  ),
                                  Text(
                                    "4.5",
                                    style: TextStyle(
                                        color: Colors.blue,
                                        fontWeight: FontWeight.bold),
                                  )
                                ],
                              ),
                            ),
                            VerticalDivider(
                              width: 1,
                              color: Colors.black,
                              thickness: 1,
                              indent: 2,
                              endIndent: 2,
                            ),
                            FlatButton() //like above
                            VerticalDivider()//like above
                            FlatButton()//like above

代码使图像变为: enter image description here

我想知道为什么没有显示 VerticalDivider 吗?

我正在使用flutter_linux_1.17.0-stable抖动sdk

1 个答案:

答案 0 :(得分:1)

我认为当您的父窗口小部件没有特定高度时会发生这种情况。

此外,如果您查看VerticalDivider的实现,则它们没有指定sizebox或容器的大小,这就是为什么IntrinsicHeight小部件不具有任何高度的原因,我们可以指定子小部件应为父级的高。

IntrinsicHeight 包装行小部件。

Flex
          direction: Axis.vertical,
          children: <Widget>[
        IntrinsicHeight( // added widget
              Row(
                          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                          children: <Widget>[