【问题标题】:Flutter/Dart, Switch: Another exception was thrown: A RenderFlex overflowed by 99640 pixels on the rightFlutter/Dart, Switch:又抛出一个异常:A RenderFlex 右侧溢出 99640 像素
【发布时间】:2019-06-07 09:46:58
【问题描述】:

我目前正在尝试向我的 android 应用程序的设置页面添加一个开关。但是,当我添加代码并尝试在模拟器上查看时,它会引发以下错误:

抛出了另一个异常:A RenderFlex 在右侧溢出了 99640 像素。

代码:

Container(
  decoration: BoxDecoration (
    color: Colors.white,
    border: Border(
      bottom: BorderSide(width: 1.0, color: Colors.grey)
    ),
  ),
  constraints: BoxConstraints (
    maxHeight: ((width * ratio) * 0.1),
    minWidth: width,
    maxWidth: width,
  ),
  child: Row(
    children: <Widget>[
      Expanded(
        child: Padding(
          padding: EdgeInsets.only(left: (width*ratio) * 0.025),
          child: Text('Highlight Identical Numbers', style: TextStyle(color: Colors.black87, fontSize: fontTextTwoScale, fontFamily: 'Roboto'))
        )
      ),
      Container(
        child: Switch(value: null, onChanged: null,)
      ),
    ],
  ),
),

我正在尝试对其进行设置,以使文本与屏幕左侧对齐,而开关与右侧对齐。我不明白小部件如何溢出 99640 像素。我没有看到 Switch 的尺寸选项。

【问题讨论】:

    标签: android dart flutter


    【解决方案1】:

    这应该很容易完成这项工作。自定义 ListTile 或将其包装在 Container 中以进行自定义。

    ListTile(
      title: Text("Setting Text One Title"),
      trailing: Switch(value: true, onChanged: (bool x) {}),
    )
    

    【讨论】:

    • 谢谢,这比我尝试做的要简单得多。
    猜你喜欢
    • 2019-07-10
    • 1970-01-01
    • 2021-12-11
    • 2020-07-28
    • 1970-01-01
    • 1970-01-01
    • 2021-09-27
    • 2021-09-07
    • 1970-01-01
    相关资源
    最近更新 更多