【问题标题】:flutter: how to get a rounded container in flutter?颤振:如何在颤动中获得圆形容器?
【发布时间】:2021-01-05 03:07:59
【问题描述】:

我是 Flutter 新手,我想做一个圆形容器。我已经这样做了,但我不知道如何调整值以适应它。有更好的解决方案吗?提前致谢。

Widget Cube() {
  return Container(
    width: 70, height: 70,
    child: Container(
      width: 64, height: 64,
      decoration: BoxDecoration(
        color: CalendarColor.blue,
        borderRadius: BorderRadius.all(
          Radius.circular(32),
        )
      ),
    ),
  );
}

我想要的是这样的。

【问题讨论】:

  • 能否请您添加一张图片...您想要什么..
  • 你能说清楚你所说的“适应它的价值”是什么意思吗?
  • 因为我只能调整 Radius.circular() 的参数使它看起来像一个圆。但我不确定它是否完全是一个圆圈。@Henok

标签: flutter


【解决方案1】:
Container(
  decoration: BoxDecoration(
    shape: BoxShape.circle //This will make container round
  )
)

【讨论】:

  • 如果我知道圆的半径,那么如何设置container的高度和宽度
  • 容器(宽度:,高度:)
【解决方案2】:

有没有更好的解决方案?

FoatingActionButton怎么样?

FloatingActionButton(
                backgroundColor: Colors.blue,
                elevation: 0.0,
                child: Text("15", style: TextStyle(color: Colors.white)),
                onPressed: () {})

【讨论】:

    【解决方案3】:

    您还可以使用 RawMaterialButton 获得更多选项,例如:

    RawMaterialButton(
          elevation: 2.0,
          fillColor:  Colors.black,
          shape: CircleBorder(),
          onPressed: () {});
          },
        )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-25
      • 2020-10-13
      • 1970-01-01
      • 2019-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多