【问题标题】:A RenderFlex overflowed by 1.3 pixels on the rightA RenderFlex 右侧溢出 1.3 个像素
【发布时间】:2022-01-04 18:53:14
【问题描述】:
Column(
  children: [
    Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        Text(
          Cart().freeDeliveryString,
          style: Theme.of(context).textTheme.headline4,
        ),
        ElevatedButton(
          onPressed: () {
            Navigator.pushNamed(context, '/');
          },
          style: ElevatedButton.styleFrom(
            primary: Colors.black,
            shape: RoundedRectangleBorder(),
            elevation: 0,
          ),
          child: Text(
            'Add More İtems',
            style:
              Theme.of(context).textTheme.headline4!.copyWith(
                color: Colors.white,
              ),
          ),
        ),
      ],
    ),
  ],
),

【问题讨论】:

标签: flutter dart visual-studio-code mobile flutter-layout


【解决方案1】:

尝试使用 Expanded 小部件包装您的行的任何一个或两个子级

仅用Expanded 小部件包装您的Text 小部件就足以解决您的错误。

   Column(
      children: [
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Expanded(
              child: Text(
                'Cart().freeDeliveryString',
                style: Theme.of(context).textTheme.headline4,
              ),
            ),
            ElevatedButton(
              onPressed: () {
                Navigator.pushNamed(context, '/');
              },
              style: ElevatedButton.styleFrom(
                primary: Colors.black,
                shape: RoundedRectangleBorder(),
                elevation: 0,
              ),
              child: Text(
                'Add More İtems',
                style: Theme.of(context).textTheme.headline4!.copyWith(
                      color: Colors.white,
                    ),
              ),
            ),
          ],
        ),
      ],
    );

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-07
    • 1970-01-01
    • 1970-01-01
    • 2021-07-24
    • 1970-01-01
    • 2019-06-08
    • 2021-09-27
    • 1970-01-01
    相关资源
    最近更新 更多