flutter 需要帮助塑造浮动操作按钮

s6fujrry  于 2023-01-06  发布在  Flutter
关注(0)|答案(2)|浏览(148)

下面是我期望的设计:

下面是它在下面代码中的当前外观:

当前代码:

我试过这个代码与半径圆:

使用Radius.circular,但这仍然没有产生预期结果,而是显示为仍在角落的不正确图标:

ni65a41a

ni65a41a1#

请尝试以下代码:

FloatingActionButton(
  onPressed: () {},
  backgroundColor: const Color.fromRGBO(238, 0, 0, 1),
  shape: const RoundedRectangleBorder( // <= Change BeveledRectangleBorder to RoundedRectangularBorder
    borderRadius: BorderRadius.only(
      topLeft: Radius.circular(30.0),
      topRight: Radius.circular(10.0),
      bottomLeft: Radius.circular(30.0),
      bottomRight: Radius.circular(30.0),
    ),
  ),
  child: const Image(
    width: 40,
    height: 40,
    image: AssetImage('images/chatbot-icon.png'),
  ),
),
z9ju0rcb

z9ju0rcb2#

BeveledRectangleBorder更改为RoundedRectangularBorder
使用以下代码:

return Scaffold(
      floatingActionButton: FloatingActionButton(
        onPressed: () {},
        backgroundColor: const Color.fromRGBO(238, 0, 0, 1),
        shape: const RoundedRectangleBorder(
            borderRadius: BorderRadius.only(
                topRight: Radius.circular(20),
                bottomLeft: Radius.circular(100),
                bottomRight: Radius.circular(100),
                topLeft: Radius.circular(100))),
      ),
    );

输出:

相关问题