我的旧代码是
maxLengthEnforced: widget.textFieldConfiguration.maxLengthEnforced,
它会产生错误
Error: No named parameter with the name 'maxLengthEnforced'.
一些指南说我应该用maxLengthEnforcement
替换maxLengthEnforced
。但是新代码:
maxLengthEnforcement: widget.textFieldConfiguration.maxLengthEnforcement,
给出新错误:
The getter 'maxLengthEnforcement' isn't defined for the class 'TextFieldConfiguration<dynamic>'.
我该怎么办?
1条答案
按热度按时间eblbsuwk1#
根据documentation,
使用新的
enum
类型MaxLengthEnforcement添加了maxLengthEnforcement
参数,以替换现已弃用的布尔型maxLengthEnforced参数现在,当它是布尔值时,在代码中使用true/false就足够了,但现在它是
enum
,因此当您将maxLengthEnforced替换为maxLengthEnforcement时,还需要在 textFieldConfiguration 中进行更改以适应此更改。简单的替换将不起作用,因此出现错误。