我怎样才能使我的图标图像在颤动中变小
How can I make my icon image smaller in flutter
我打算使用我的自定义图标而不是 material 图标,但由于某些原因我无法缩小图像。关于如何使图像变小的任何建议,如右侧的 material 图标。
我应用了宽度和高度,但由于某些原因它们不能比这更小。 (附图)
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.asset(
"your/asset/path",
width: PREFERRED_WIDTH,
height: PREFERRED_HEIGHT,
),
也许你可以像这样添加 prefixIconConstraints
prefixIconConstraints: BoxConstraints(
maxWidth: 20.0,
maxHeight: 20.0,
),
我打算使用我的自定义图标而不是 material 图标,但由于某些原因我无法缩小图像。关于如何使图像变小的任何建议,如右侧的 material 图标。
我应用了宽度和高度,但由于某些原因它们不能比这更小。 (附图)
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.asset(
"your/asset/path",
width: PREFERRED_WIDTH,
height: PREFERRED_HEIGHT,
),
也许你可以像这样添加 prefixIconConstraints
prefixIconConstraints: BoxConstraints(
maxWidth: 20.0,
maxHeight: 20.0,
),