【发布时间】:2021-03-02 20:16:04
【问题描述】:
我使用包 Flutter SVG 能够将 SVG 图标资源添加到我的颤振应用程序中。
它按预期工作,当我将它用作普通小部件时,我可以通过添加 width: xx 来调整它的大小.. 但是当我在 textField 中用作 prefixIcon 时,它没有被调整大小,这是我的代码:
TextFormField(
controller: vendorPasswordController,
style:
TextStyle(color: Colors.white),
obscureText: passwordHidden,
decoration: InputDecoration(
enabledBorder:
UnderlineInputBorder(
borderSide: BorderSide(
color: Colors.white),
),
prefixIcon:
SvgPicture.asset(
'assets/images/password_icon.svg',
semanticsLabel: 'vendor_password',
width: 20,
),
suffixIcon: IconButton(
icon:
SvgPicture.asset(
'assets/images/show_icon.svg',
width: 20,
),
onPressed: () {
changePasswordHiddenState();
},
),
labelText: 'كلمة المرور',
labelStyle: TextStyle(
color: Colors.white,
fontSize: 16)),
validator: (value) {
if (value.isEmpty) {
return "كلمة المرور مطلوبة";
}
return null;
},
),
请注意,我使用了另一个 SVG 资产作为 suffixICon,它与 width 参数完美配合。但作为PrefixIcon,它永远不会调整大小。
【问题讨论】:
-
找到方法了吗?
标签: android flutter svg icons assets