简体   繁体   English

如何在 flutter 中使我的图标图像更小

[英]How can I make my icon image smaller in flutter

I'm planning to use my custom icon instead of using material icon but some reason I cannot make the image smaller.我打算使用我的自定义图标而不是使用材质图标,但由于某种原因我无法使图像变小。 Any idea of suggestion on how I can make the image to smaller like the material icon on the right side.关于如何使图像变小的任何建议,如右侧的材料图标。

I'm applied the width and height but some reason they can't get smaller than this.我应用了宽度和高度,但出于某种原因,它们不能比这小。 (attached image) (附图)

  Widget textField() {
    return TextField(
      enabled: false,
      decoration: InputDecoration(
          contentPadding: EdgeInsets.symmetric(vertical: 10.0),
          focusedBorder: OutlineInputBorder(
            borderSide: BorderSide(color: Colors.transparent),
            borderRadius: BorderRadius.circular(10.0),
          ),
          border: OutlineInputBorder(
            borderSide: BorderSide(color: Colors.white),
            borderRadius: BorderRadius.all(
              Radius.circular(10.0),
            ),
          ),
          hintStyle: TextStyle(
              fontSize: 18, color: Theme.of(context).secondaryHeaderColor),
          hintText: 'Search',
          prefixIcon: Padding(
            padding: EdgeInsets.all(2),
            child: SizedBox(
              width: 10,
              height: 10,
              child: Image.asset(
                'assets/icons/nav-icons/Explore.png',
              ),
            ),
          ),
          suffixIcon:
              Icon(Icons.mic, color: Theme.of(context).secondaryHeaderColor),
          filled: true,
          fillColor: Theme.of(context).primaryColor),
    );
  }
  

在此处输入图像描述

Image widget has width and height property图像小部件具有宽度和高度属性

Image.asset(
    "your/asset/path",
    width: PREFERRED_WIDTH,
    height: PREFERRED_HEIGHT,
),

Maybe you can add the prefixIconConstraints like this也许你可以像这样添加 prefixIconConstraints

 prefixIconConstraints: BoxConstraints(
     maxWidth: 20.0,
     maxHeight: 20.0,
 ),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM