flutter:右侧溢出像素

ecr0jaav  于 2022-11-30  发布在  Flutter
关注(0)|答案(2)|浏览(285)

下面是我的代码:

return Scaffold(
  appBar: AppBar(
    backgroundColor: Colors.grey[900],
    leading: IconButton(
      icon: const Icon(Icons.arrow_back),
      onPressed: () => Navigator.of(context).pop(false),
    ),
  ),
  backgroundColor: Colors.grey[900],
  body: Visibility(
      visible: questionLoaded,
      child: Builder(builder: (context) {
        return Wrap(
          spacing: 8.0,
          runSpacing: 4.0,
          direction: Axis.horizontal,
          children: [
            Container(
              width: double.infinity,
              child: Text(
                question!.question,
                textAlign: TextAlign.center,
                style: GoogleFonts.mukta(
                  textStyle: TextStyle(
                      color: Colors.amber,
                      fontSize: 24,
                      shadows: const [
                        Shadow(
                            color: Colors.white,
                            offset: Offset.zero,
                            blurRadius: 15)
                      ]),
                ),
              ),
            ),
            if (question?.answer1 != "")
              RadioButton(
                textStyle: TextStyle(color: Colors.white),
                description: (question?.answer1)!,
                value: "1",
                groupValue: _decision,
                onChanged: (value) => setState(
                  () => _decision = value!,
                ),
              ),
            if (question?.answer2 != "")
              RadioButton(
                textStyle: TextStyle(color: Colors.white),
                description: (question?.answer2)!,
                value: "2",
                groupValue: _decision,
                onChanged: (value) => setState(
                  () => _decision = value!,
                ),
              ),
            if (question?.answer3 != "")
              RadioButton(
                textStyle: TextStyle(color: Colors.white),
                description: (question?.answer3)!,
                value: "3",
                groupValue: _decision,
                onChanged: (value) => setState(
                  () => _decision = value!,
                ),
              ),
            if (question?.answer4 != "")
              RadioButton(
                textStyle: TextStyle(color: Colors.white),
                description: (question?.answer4)!,
                value: "4",
                groupValue: _decision,
                onChanged: (value) => setState(
                  () => _decision = value!,
                ),
              ),
          ],
        );
      })),
);

这会产生以下问题:

你知道为什么吗?我该怎么修?

mklgxw1f

mklgxw1f1#

将文本小工具FlexibleExpanded小工具换行。

Expnaded( child: Text( question!.question,....
0dxa2lsx

0dxa2lsx2#

如果文本在列中换行,则列应在展开小部件中换行。

Expanded(
    child: Column(
      children: [
        Text(
          'datadatadatadatadatadata',
          overflow: TextOverflow.ellipsis,
        )
      ],
    ),
  ),

但是如果你的文本是换行的,那么你的文本应该是换行的。

Row(
    children: [
      Expanded(
        child: Text(
          'datadatadatadatadatadata',
          overflow: TextOverflow.ellipsis,
        ),
      )
    ],
  ),

相关问题