flutter 无法在容器的底部右侧设置BorderRadius

rqmkfv5c  于 2023-08-07  发布在  Flutter
关注(0)|答案(2)|浏览(156)

我想给予容器的右下角半径。为此,我设置了容器的右边框和底部边框。
但是,它不允许我设置右下角的corder半径。
下面是代码。

Container(
          padding: EdgeInsets.all(8),
          decoration: BoxDecoration(
            borderRadius: BorderRadius.only(
              bottomRight: Radius.circular(6),
            ),
            border: Border(
              right: BorderSide(
                  color: Colors.red,
                  width: 1),
              bottom: BorderSide(
                  color: Colors.red,
                  width: 1),
            ),
          ),
          child: Text(
            blockName,
            textAlign: TextAlign.left,
          ),
        )

字符串
当我在控制台上运行上面的代码时,我得到了以下错误。

════════ Exception caught by rendering library ═════════════════════════════════
A borderRadius can only be given for a uniform Border.
The relevant error-causing widget was
Container                                      transfer_content_screen.dart:537
════════════════════════════════════════════════════════════════════════════════

e7arh2l6

e7arh2l61#

请尝试此代码

ClipRRect(
        borderRadius: BorderRadius.only(
          bottomRight: Radius.circular(30),
        ),
        child: Container(
          padding: EdgeInsets.all(8),
          decoration: BoxDecoration(
            color: Colors.white,
            border: Border(
              right: BorderSide(
                color: Colors.red,
                width: 2.0,
              ),
              bottom: BorderSide(
                color: Colors.red,
                width: 2.0,
              ),
            ),
          ),
          child: Text(
            "blockName",
            textAlign: TextAlign.left,
          ),
        ),
      ),

字符串


的数据

6ovsh4lw

6ovsh4lw2#

我找到了一个变通办法,试试这个

Center(
      child: SizedBox(
        height: 40,
        width: 90,
        child: Stack(
          children: [
            Container(
              padding: const EdgeInsets.all(8),
              decoration: const BoxDecoration(
                color: Colors.red,
                borderRadius: BorderRadius.only(
                  bottomRight: Radius.circular(6),
                ),
              ),
            ),
            Padding(
              padding: const EdgeInsets.only(right: 1, bottom: 1),
              child: Container(
                height: double.infinity,
                width: double.infinity,
                padding: const EdgeInsets.all(8),
                decoration: const BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.only(
                    bottomRight: Radius.circular(6),
                  ),
                ),
                child: const Center(
                  child:  Text(
                    "blockName",
                    textAlign: TextAlign.left,
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    ),

字符串


的数据

相关问题