【问题标题】:Flutter leading image height width not working颤振前导图像高度宽度不起作用
【发布时间】:2021-03-08 10:21:44
【问题描述】:

我在 appbar 中的领先位置添加了一个图像作为图标。但是它的宽度高度不起作用我尝试将它包装在一个容器中并给出宽度和高度但不知道为什么它没有减少

leading:  Padding(
                padding: const EdgeInsets.only(left: 5),
                child: GestureDetector(
                  onTap: () {
                    setState(() {
                      xOffset = 280;
                      yOffset = 150;
                      scaleFactor = 0.6;
                      isDrawerOpen = true;
                    });
                  },
                  child: Container(
                    width: Width * 0.01,
                    child: Image.asset('images/ic.png'),
                  ),
                ),
              ),

【问题讨论】:

    标签: flutter


    【解决方案1】:

    试试

    leading:  InkWell(              
                  onTap: () {
                    setState(() {
                      xOffset = 280;
                      yOffset = 150;
                      scaleFactor = 0.6;
                      isDrawerOpen = true;
                    });
                  },
                  child:  Container(
                  padding: EdgeInsets.fromLTRB(5, 0, 0, 0),
                  decoration: BoxDecoration(
                    image: const DecorationImage(
                      image: AssetImage('images/ic.png'),
                      fit: BoxFit.cover,
                    ),
                    border: Border.all(
                      color: Colors.transparent,
                      width: 18,
                    ),
                    borderRadius: BorderRadius.circular(12),
                  ),
                )
    

    或

    leading:  InkWell(              
                  onTap: () {
                    setState(() {
                      xOffset = 280;
                      yOffset = 150;
                      scaleFactor = 0.6;
                      isDrawerOpen = true;
                    });
                  },
                  child: Container(
                  padding: EdgeInsets.fromLTRB(5, 0, 0, 0),
                  child: CircleAvatar(
                    radius: 30.0,
                    child: Image.asset('images/ic.png'),
                    backgroundColor: Colors.transparent,
                  )
                ),
    

    其中一个会起作用..

    【讨论】:

    • 做了一些改变。如果这不起作用,我需要更多关于你想要达到的目标的信息?
    猜你喜欢
    • 2012-05-03
    • 2012-01-15
    • 1970-01-01
    • 2020-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-09
    相关资源
    最近更新 更多