【问题标题】:flutter: Right overflowed by pixels颤动:右溢出像素
【发布时间】:2022-11-29 00:19:21
【问题描述】:

这是我的代码:

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!,
                ),
              ),
          ],
        );
      })),
);

这会产生以下问题:

知道为什么以及如何解决它吗?

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    包装您的文本小部件 FlexibleExpanded 小部件。

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

    【讨论】:

      猜你喜欢
      • 2023-01-30
      • 1970-01-01
      • 2020-12-06
      • 1970-01-01
      • 2020-03-03
      • 2021-10-06
      • 2018-09-03
      • 2019-10-14
      • 1970-01-01
      相关资源
      最近更新 更多