flutter 我希望单选按钮小部件和文本小部件内联

34gzjxbg  于 2023-02-13  发布在  Flutter
关注(0)|答案(2)|浏览(149)

我希望单个选中的单选按钮小部件和文本小部件在同一行中。即使我尝试将其与行换行,它也不会工作。我希望它像下面的图像。I want thisBut I got this。提前感谢!

Column(
            children: [
              RadioListTile(
                title: Padding(
                  padding: const EdgeInsets.only(left: 50),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: [
                      ///use your image
                      Text(
                        "  English",
                        style: TextStyle(
                          color: Color(0xff000000),
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                    ],
                  ),
                ),
                value: "English",
                groupValue: "english",
                shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(5)),
                onChanged: (value) {
                  setState(() {});
                },
                tileColor: Color(0xff28e8df),
              ),
              Container(
                  decoration: BoxDecoration(
                      color: Color(0xffbebdbd),
                      border: Border.all(color: Color(0xffbebdbd)),
                      borderRadius: BorderRadius.circular(5)),
                  child: Padding(
                      padding: EdgeInsets.all(10.0),
                      child: Text("العربية",
                          style: TextStyle(
                              fontSize: 17,
                              color: Color(0xff000000),
                              fontWeight: FontWeight.bold)))),
            ],
          ),
hrirmatl

hrirmatl1#

您必须使用Row小部件,并使用Expanded包裹其中的每个子部件,因为RadioListTile希望获得其父部件的宽度,而Row则等待其子部件进行渲染,这样它就可以知道自己的宽度。
通过使用ExpandedRow知道它必须接受所有可能的,并且它的子对象可以正确地适合它。

zdwk9cvp

zdwk9cvp2#

尝试这个更新,我希望它能解决这个问题

Container(
          width: MediaQuery.of(context).size.width,
          child: Row(
            children: [
              Container(
                width: MediaQuery.of(context).size.width / 2,
                height: 50,
                child: RadioListTile(
                  title: Padding(
                    padding: const EdgeInsets.only(left: 50),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.start,
                      children: [
                        ///use your image
                        Text(
                          "  English",
                          style: TextStyle(
                            color: Color(0xff000000),
                            fontWeight: FontWeight.bold,
                          ),
                        ),
                      ],
                    ),
                  ),
                  value: "English",
                  groupValue: "english",
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(5),
                  ),
                  onChanged: (value) {
                    setState(() {});
                  },
                  tileColor: Color(0xff28e8df),
                ),
              ),
              Container(
                width: MediaQuery.of(context).size.width / 2,
                decoration: BoxDecoration(
                  color: Color(0xffbebdbd),
                  border: Border.all(color: Color(0xffbebdbd)),
                  borderRadius: BorderRadius.circular(5),
                ),
                child: Padding(
                  padding: EdgeInsets.all(10.0),
                  child: Text(
                    "العربية",
                    style: TextStyle(
                      fontSize: 17,
                      color: Color(0xff000000),
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),

相关问题