Flutter 在圆形容器内创建单选按钮

标签 flutter

      return Material(
      child: Center(
        child: Stack(
          children: <Widget>[
            Container(
              alignment: Alignment.center,
              child: new Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.start,
                children: <Widget>[
                  Stack(
                    children: <Widget>[Positioned(
                      top: 15,
                      left: 5,
                      child:  Container(
                        alignment: Alignment.center,
                        width: 25.0,
                        height: 25.0,
                        decoration: new BoxDecoration(
                          shape: BoxShape.circle,
                          color: const Color(0XFFE6E6E6),
                          border: new Border.all(
                            width: 0.0,
                            color: Colors.white,
                          ),
                        ),
                      )
                    ),
                      Center(                                               
                        child: Radio(
                          groupValue: null,
                          onChanged: (Null value) {},
                          value: null,
                        ),
                      )
                    ],
                  )
  }

我在 gridview 中实现单选按钮我想在容器内创建一个单选按钮。我在上面尝试的代码没有将单选按钮放在容器内。

最佳答案

试试这个。您可以根据需要获取代码。

Material(
        child: Container(
      height: 200.0,
      decoration: new BoxDecoration(
        color: Colors.white,
        shape: BoxShape.circle,
      ),
      child: Center(
        child: Stack(
          children: <Widget>[
            Container(
              alignment: Alignment.center,
              child: new Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Stack(
                    alignment: Alignment.center,
                    children: <Widget>[
                      Container(
                        alignment: Alignment.center,
                        width: 20.0,
                        height: 20.0,
                        decoration: new BoxDecoration(
                          shape: BoxShape.circle,
                          color: const Color(0XFFE6E6E6),
                          border: new Border.all(
                            width: 0.0,
                            color: Colors.white,
                          ),
                        ),
                      ),
                      Padding(
                        padding: EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0),
                        child: Radio(
                          groupValue: null,
                          onChanged: (Null value) {},
                          value: null,
                        ),
                      )
                    ],
                  )
                ],
                // child: contentInCircle,
              ),
            ),
          ],
        ),
      ),
    ))

关于Flutter 在圆形容器内创建单选按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54944577/

相关文章:

dart - Flutter通知在Android设备上不起作用

flutter - Flutter-如何在List View Builder中扩展容器以填充整个空间?

flutter - 如何在用 singlechildscrollview 包裹的列内使用间隔器?

dart - 如何在Flutter中将非字符串数据传递到命名路由?

dart - FutureBuilder Flutter 中未处理的异常

flutter - 将 "multiple"有状态和无状态小部件存储在一个 dart 文件中。可以吗?

Flutter 将 RenderObject 转换为 RenderBox

flutter - 我的 Flutter 项目可以有不同的 Android 和 iOS 版本号吗?

json - 将 json 映射转换为 flutter 中的列表

flutter - 在下面的代码中,当点击按钮时,为什么不能调用[print ("BBB' s build function.")]?