RenderFlex在右侧溢出了74个像素

时间:2020-05-14 11:57:58

标签: flutter flutter-layout

出现此问题(主要是由于url的图像)而尝试扩展或灵活仍然无法解决此问题。

 child: AppBar(
        centerTitle: true,
        title: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            Row(
              children: <Widget>[
                Image.asset("assets/images/ic_title_menu.png",height: 16.0,width: 16.0,),
                SizedBox(width: 10,),
                Image.asset("assets/images/ic_title_search.png",height: 16.0,width: 16.0,)
              ],
            ),
            Row(
              children: <Widget>[
                  Image.network("http://rcwebsitecss.gbfine.com/Mobile_SportsII/images/logo/display_logo_007.png",),
              ],
            ),
            Row(
              children: <Widget>[
                Column(
                  children: <Widget>[
                    Text(
                      'cgb_test_08',
                       style: TextStyle(color: Colors.white, fontSize: 12),
                    ),
                    Text(
                      '1000',
                       style: TextStyle(color: Colors.white, fontSize: 12),
                    )
                  ],
                ),
                SizedBox(width: 10,),
                Image.asset("assets/images/ic_user_center.png",height: 16.0,width: 16.0,)
              ],
            ),
          ],
        ),
      ),
    ),
    body: Center(

3 个答案:

答案 0 :(得分:1)

您可以使用 Flexible 小部件。

    Flexible(
              child: Image.network(
                "http://rcwebsitecss.gbfine.com/Mobile_SportsII/images/logo/display_logo_007.png",
                fit: BoxFit.fitWidth,
              ),
            ),

答案 1 :(得分:0)

尝试一下。

import 'package:flutter/material.dart';

class Amd extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        image: DecorationImage(
          image: NetworkImage("Image Address"),
        ),
      ),
      constraints: BoxConstraints(
        maxWidth: 100,
        maxHeight: 200,
      ),
    );
  }
}

答案 2 :(得分:0)

尝试将您的Image.network包装到具有特定高度和宽度的容器中,或按照UTKARSH Sharma的建议设置约束条件